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.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
User description
PR_036
PR Type
Enhancement
Description
Use provided
waitUntilcallback for pending revalidates instead of fallback strategyAdd debug logging to track pending revalidates promise resolution
Update test to use
retryfor more reliable revalidation completion detectionDiagram Walkthrough
flowchart LR A["Pending Revalidates"] --> B["Check for waitUntil callback"] B --> C{waitUntil available?} C -->|Yes| D["Pass promise to waitUntil"] C -->|No| E["Fallback to options.waitUntil"] D --> F["Add debug logging"] E --> F F --> G["Promise resolves"]File Walkthrough
base-server.ts
Use provided waitUntil for pending revalidatespackages/next/src/server/base-server.ts
pendingWaitUntilfromcontext.renderOptscontext.renderOpts.waitUntilcallback is availablewaitUntilcallback if providedpendingWaitUntilto prevent fallback handling insendResponsemodule.ts
Add debug logging for pending revalidates completionpackages/next/src/server/route-modules/app-route/module.ts
.finally()block to pending revalidates promiseNEXT_PRIVATE_DEBUG_CACHEenvironment variable for conditionallogging
app-render.tsx
Prefer waitUntil callback over options assignmentpackages/next/src/server/app-render/app-render.tsx
pendingPromisevariablerenderOpts.waitUntilcallback exists before assigningwaitUntilcallback if available, otherwise useoptions.waitUntil.finally()block with debug logging for promise completionapp-fetch-deduping.test.ts
Use retry for revalidation completion detectiontest/e2e/app-dir/app-fetch-deduping/app-fetch-deduping.test.ts
waitForimport withretryfromnext-test-utilsretryloop for revalidation completion