@@ -365,6 +365,7 @@ import { readAppRouteHandlerCacheResponse as __readAppRouteHandlerCacheResponse
365365import {
366366 finalizeAppPageHtmlCacheResponse as __finalizeAppPageHtmlCacheResponse,
367367 readAppPageCacheResponse as __readAppPageCacheResponse,
368+ scheduleAppPageRscCacheWrite as __scheduleAppPageRscCacheWrite,
368369} from ${ JSON . stringify ( appPageCachePath ) } ;
369370import {
370371 buildAppPageHtmlResponse as __buildAppPageHtmlResponse,
@@ -2792,7 +2793,9 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
27922793 // The RSC stream is consumed lazily - components render when chunks are read.
27932794 // If we clear context now, headers()/cookies() will fail during rendering.
27942795 // Context will be cleared when the next request starts (via runWithRequestContext).
2796+ const __dynamicUsedInRsc = consumeDynamicUsage();
27952797 const __rscResponsePolicy = __resolveAppPageRscResponsePolicy({
2798+ dynamicUsedDuringBuild: __dynamicUsedInRsc,
27962799 isDynamicError,
27972800 isForceDynamic,
27982801 isForceStatic,
@@ -2814,21 +2817,22 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
28142817 // For ISR-eligible RSC requests in production: write rscData to its own key.
28152818 // HTML is stored under a separate key (written by the HTML path below) so
28162819 // these writes never race or clobber each other.
2817- if (process.env.NODE_ENV === "production" && __isrRscDataPromise) {
2818- const __isrKeyRsc = __isrRscKey(cleanPathname);
2819- const __revalSecsRsc = revalidateSeconds;
2820- const __rscWritePromise = (async () => {
2821- try {
2822- const __rscDataForCache = await __isrRscDataPromise;
2823- const __pageTags = __pageCacheTags(cleanPathname, getCollectedFetchTags());
2824- await __isrSet(__isrKeyRsc, { kind: "APP_PAGE", html: "", rscData: __rscDataForCache, headers: undefined, postponed: undefined, status: 200 }, __revalSecsRsc, __pageTags);
2825- __isrDebug?.("RSC cache written", __isrKeyRsc);
2826- } catch (__rscWriteErr) {
2827- console.error("[vinext] ISR RSC cache write error:", __rscWriteErr);
2828- }
2829- })();
2830- _getRequestExecutionContext()?.waitUntil(__rscWritePromise);
2831- }
2820+ __scheduleAppPageRscCacheWrite({
2821+ capturedRscDataPromise: process.env.NODE_ENV === "production" ? __isrRscDataPromise : null,
2822+ cleanPathname,
2823+ consumeDynamicUsage,
2824+ dynamicUsedDuringBuild: __dynamicUsedInRsc,
2825+ getPageTags() {
2826+ return __pageCacheTags(cleanPathname, getCollectedFetchTags());
2827+ },
2828+ isrDebug: __isrDebug,
2829+ isrRscKey: __isrRscKey,
2830+ isrSet: __isrSet,
2831+ revalidateSeconds,
2832+ waitUntil(promise) {
2833+ _getRequestExecutionContext()?.waitUntil(promise);
2834+ },
2835+ });
28322836 return __rscResponse;
28332837 }
28342838
0 commit comments