Use provided waitUntil for pending revalidates (#74164)#6
Use provided waitUntil for pending revalidates (#74164)#6MitchLewis930 wants to merge 1 commit intopr_036_beforefrom
Conversation
Currently we are using `pendingWaitUntil` on `renderOpts` to handle pending revalidations (fetch updates and revalidate tag calls). This uses our old strategy of `waitUntil` inside of `sendResponse` which just keeps the stream open until the promise resolves. This isn't ideal if we have a proper waitUntil strategy provided so this updates to ensure we use that instead if available. Also adds some debug logs so we can track when this pending revalidates promise is resolved.
📝 WalkthroughWalkthroughThese changes refactor how pending promises are managed in the Next.js server-side render pipeline, introducing centralized promise aggregation with debug instrumentation, and updating a test utility to use a retry-based approach instead of fixed delays. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used🧬 Code graph analysis (2)packages/next/src/server/route-modules/app-route/module.ts (1)
test/e2e/app-dir/app-fetch-deduping/app-fetch-deduping.test.ts (1)
🔇 Additional comments (5)
✏️ Tip: You can disable this entire section by setting Comment |
|
@CodeRabbit full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/next/src/server/base-server.ts (1)
2544-2561:⚠️ Potential issue | 🟠 MajorUse the adjusted
pendingWaitUntilwhen sending the response.You clear the local
pendingWaitUntilwhenwaitUntilis available, butsendResponsestill receivescontext.renderOpts.pendingWaitUntil(Line 2556–2561). That keeps the old “wait for pending” behavior and defeats the intended change. Pass the local variable (or clearrenderOpts.pendingWaitUntil) so the response can close when waitUntil is provided.✅ Suggested fix
- await sendResponse( - req, - res, - response, - context.renderOpts.pendingWaitUntil - ) + await sendResponse( + req, + res, + response, + pendingWaitUntil + )
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/next/src/server/app-render/app-render.tsxpackages/next/src/server/base-server.tspackages/next/src/server/route-modules/app-route/module.tstest/e2e/app-dir/app-fetch-deduping/app-fetch-deduping.test.ts
🧰 Additional context used
🧬 Code graph analysis (2)
packages/next/src/server/route-modules/app-route/module.ts (1)
packages/next/src/server/web/sandbox/context.ts (1)
requestStore(248-250)
test/e2e/app-dir/app-fetch-deduping/app-fetch-deduping.test.ts (1)
test/lib/next-test-utils.ts (1)
retry(792-822)
🔇 Additional comments (5)
packages/next/src/server/route-modules/app-route/module.ts (1)
595-607: Debug log on pending revalidates looks good.The
finally()hook adds useful traceability without altering behavior, and the env gate keeps it non-intrusive.test/e2e/app-dir/app-fetch-deduping/app-fetch-deduping.test.ts (2)
1-1: Import aligns with new retry-based flow.
115-118: Retry-based wait makes the test more robust.packages/next/src/server/app-render/app-render.tsx (2)
1301-1317: Good use of providedwaitUntilwhen available.
1468-1484: Consistent pending revalidate handling in the dynamic path.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
PR_036
Summary by CodeRabbit
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.