vinext 0.0.43 → 0.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/dist/build/google-fonts/build-url.d.ts +10 -0
  2. package/dist/build/google-fonts/build-url.js +30 -0
  3. package/dist/build/google-fonts/build-url.js.map +1 -0
  4. package/dist/build/google-fonts/font-data.js +24985 -0
  5. package/dist/build/google-fonts/font-data.js.map +1 -0
  6. package/dist/build/google-fonts/font-metadata.d.ts +17 -0
  7. package/dist/build/google-fonts/font-metadata.js +7 -0
  8. package/dist/build/google-fonts/font-metadata.js.map +1 -0
  9. package/dist/build/google-fonts/get-axes.d.ts +7 -0
  10. package/dist/build/google-fonts/get-axes.js +39 -0
  11. package/dist/build/google-fonts/get-axes.js.map +1 -0
  12. package/dist/build/google-fonts/sort-variants.d.ts +5 -0
  13. package/dist/build/google-fonts/sort-variants.js +14 -0
  14. package/dist/build/google-fonts/sort-variants.js.map +1 -0
  15. package/dist/build/google-fonts/validate.d.ts +28 -0
  16. package/dist/build/google-fonts/validate.js +56 -0
  17. package/dist/build/google-fonts/validate.js.map +1 -0
  18. package/dist/build/layout-classification.d.ts +1 -1
  19. package/dist/build/layout-classification.js.map +1 -1
  20. package/dist/build/nitro-route-rules.d.ts +1 -1
  21. package/dist/build/nitro-route-rules.js.map +1 -1
  22. package/dist/build/precompress.d.ts +1 -1
  23. package/dist/build/precompress.js.map +1 -1
  24. package/dist/build/prerender.d.ts +1 -7
  25. package/dist/build/prerender.js +7 -3
  26. package/dist/build/prerender.js.map +1 -1
  27. package/dist/build/run-prerender.d.ts +1 -13
  28. package/dist/build/run-prerender.js +5 -1
  29. package/dist/build/run-prerender.js.map +1 -1
  30. package/dist/build/standalone.d.ts +1 -1
  31. package/dist/build/standalone.js.map +1 -1
  32. package/dist/client/vinext-next-data.d.ts +1 -3
  33. package/dist/cloudflare/kv-cache-handler.d.ts +5 -0
  34. package/dist/cloudflare/kv-cache-handler.js +56 -35
  35. package/dist/cloudflare/kv-cache-handler.js.map +1 -1
  36. package/dist/cloudflare/tpr.d.ts +1 -16
  37. package/dist/cloudflare/tpr.js +1 -1
  38. package/dist/cloudflare/tpr.js.map +1 -1
  39. package/dist/config/dotenv.d.ts +1 -1
  40. package/dist/config/dotenv.js.map +1 -1
  41. package/dist/deploy.d.ts +1 -1
  42. package/dist/deploy.js +21 -4
  43. package/dist/deploy.js.map +1 -1
  44. package/dist/entries/app-rsc-entry.js +93 -15
  45. package/dist/entries/app-rsc-entry.js.map +1 -1
  46. package/dist/index.js +8 -2
  47. package/dist/index.js.map +1 -1
  48. package/dist/init.d.ts +1 -1
  49. package/dist/init.js.map +1 -1
  50. package/dist/plugins/async-hooks-stub.d.ts +1 -2
  51. package/dist/plugins/async-hooks-stub.js +2 -2
  52. package/dist/plugins/async-hooks-stub.js.map +1 -1
  53. package/dist/plugins/fonts.d.ts +1 -20
  54. package/dist/plugins/fonts.js +42 -21
  55. package/dist/plugins/fonts.js.map +1 -1
  56. package/dist/plugins/server-externals-manifest.d.ts +1 -11
  57. package/dist/plugins/server-externals-manifest.js +1 -1
  58. package/dist/plugins/server-externals-manifest.js.map +1 -1
  59. package/dist/routing/app-router.d.ts +2 -1
  60. package/dist/routing/app-router.js +12 -6
  61. package/dist/routing/app-router.js.map +1 -1
  62. package/dist/routing/file-matcher.d.ts +1 -3
  63. package/dist/routing/file-matcher.js +1 -1
  64. package/dist/routing/file-matcher.js.map +1 -1
  65. package/dist/routing/utils.d.ts +1 -29
  66. package/dist/routing/utils.js +1 -1
  67. package/dist/routing/utils.js.map +1 -1
  68. package/dist/server/app-browser-entry.js +183 -99
  69. package/dist/server/app-browser-entry.js.map +1 -1
  70. package/dist/server/app-browser-state.d.ts +1 -1
  71. package/dist/server/app-browser-state.js.map +1 -1
  72. package/dist/server/app-browser-stream.d.ts +1 -1
  73. package/dist/server/app-browser-stream.js.map +1 -1
  74. package/dist/server/app-elements.d.ts +1 -2
  75. package/dist/server/app-elements.js +1 -1
  76. package/dist/server/app-elements.js.map +1 -1
  77. package/dist/server/app-page-boundary-render.d.ts +3 -1
  78. package/dist/server/app-page-boundary-render.js +2 -0
  79. package/dist/server/app-page-boundary-render.js.map +1 -1
  80. package/dist/server/app-page-boundary.d.ts +2 -1
  81. package/dist/server/app-page-boundary.js +10 -5
  82. package/dist/server/app-page-boundary.js.map +1 -1
  83. package/dist/server/app-page-cache.d.ts +1 -1
  84. package/dist/server/app-page-cache.js.map +1 -1
  85. package/dist/server/app-page-execution.d.ts +4 -2
  86. package/dist/server/app-page-execution.js +19 -4
  87. package/dist/server/app-page-execution.js.map +1 -1
  88. package/dist/server/app-page-probe.d.ts +1 -1
  89. package/dist/server/app-page-probe.js.map +1 -1
  90. package/dist/server/app-page-render.d.ts +2 -2
  91. package/dist/server/app-page-render.js.map +1 -1
  92. package/dist/server/app-page-request.d.ts +1 -1
  93. package/dist/server/app-page-request.js.map +1 -1
  94. package/dist/server/app-page-response.d.ts +1 -1
  95. package/dist/server/app-page-response.js.map +1 -1
  96. package/dist/server/app-page-route-wiring.d.ts +2 -8
  97. package/dist/server/app-page-route-wiring.js +13 -3
  98. package/dist/server/app-page-route-wiring.js.map +1 -1
  99. package/dist/server/app-page-stream.d.ts +2 -1
  100. package/dist/server/app-page-stream.js +5 -3
  101. package/dist/server/app-page-stream.js.map +1 -1
  102. package/dist/server/app-route-handler-cache.d.ts +1 -1
  103. package/dist/server/app-route-handler-cache.js.map +1 -1
  104. package/dist/server/app-route-handler-execution.d.ts +1 -1
  105. package/dist/server/app-route-handler-execution.js +9 -4
  106. package/dist/server/app-route-handler-execution.js.map +1 -1
  107. package/dist/server/app-route-handler-policy.d.ts +6 -2
  108. package/dist/server/app-route-handler-policy.js +8 -3
  109. package/dist/server/app-route-handler-policy.js.map +1 -1
  110. package/dist/server/app-route-handler-response.d.ts +1 -1
  111. package/dist/server/app-route-handler-response.js.map +1 -1
  112. package/dist/server/app-route-handler-runtime.d.ts +1 -1
  113. package/dist/server/app-route-handler-runtime.js +1 -1
  114. package/dist/server/app-route-handler-runtime.js.map +1 -1
  115. package/dist/server/app-router-entry.js +8 -1
  116. package/dist/server/app-router-entry.js.map +1 -1
  117. package/dist/server/app-server-action-execution.d.ts +35 -0
  118. package/dist/server/app-server-action-execution.js +105 -0
  119. package/dist/server/app-server-action-execution.js.map +1 -0
  120. package/dist/server/app-ssr-entry.js +2 -1
  121. package/dist/server/app-ssr-entry.js.map +1 -1
  122. package/dist/server/app-ssr-stream.d.ts +1 -1
  123. package/dist/server/app-ssr-stream.js.map +1 -1
  124. package/dist/server/csp.d.ts +1 -2
  125. package/dist/server/csp.js +1 -1
  126. package/dist/server/csp.js.map +1 -1
  127. package/dist/server/dev-module-runner.d.ts +1 -1
  128. package/dist/server/dev-module-runner.js.map +1 -1
  129. package/dist/server/middleware-request-headers.d.ts +1 -3
  130. package/dist/server/middleware-request-headers.js +4 -4
  131. package/dist/server/middleware-request-headers.js.map +1 -1
  132. package/dist/server/middleware.d.ts +1 -1
  133. package/dist/server/middleware.js.map +1 -1
  134. package/dist/server/pages-api-route.d.ts +1 -1
  135. package/dist/server/pages-api-route.js.map +1 -1
  136. package/dist/server/pages-i18n.d.ts +2 -3
  137. package/dist/server/pages-i18n.js +1 -1
  138. package/dist/server/pages-i18n.js.map +1 -1
  139. package/dist/server/pages-node-compat.d.ts +1 -2
  140. package/dist/server/pages-node-compat.js +1 -1
  141. package/dist/server/pages-node-compat.js.map +1 -1
  142. package/dist/server/pages-page-data.d.ts +1 -1
  143. package/dist/server/pages-page-data.js.map +1 -1
  144. package/dist/server/pages-page-response.d.ts +1 -1
  145. package/dist/server/pages-page-response.js.map +1 -1
  146. package/dist/server/prod-server.js +18 -13
  147. package/dist/server/prod-server.js.map +1 -1
  148. package/dist/server/request-pipeline.d.ts +33 -1
  149. package/dist/server/request-pipeline.js +44 -2
  150. package/dist/server/request-pipeline.js.map +1 -1
  151. package/dist/server/socket-error-backstop.d.ts +17 -0
  152. package/dist/server/socket-error-backstop.js +129 -0
  153. package/dist/server/socket-error-backstop.js.map +1 -0
  154. package/dist/server/static-file-cache.d.ts +1 -1
  155. package/dist/server/static-file-cache.js.map +1 -1
  156. package/dist/shims/cache-runtime.js +16 -3
  157. package/dist/shims/cache-runtime.js.map +1 -1
  158. package/dist/shims/cache.d.ts +3 -1
  159. package/dist/shims/cache.js +83 -22
  160. package/dist/shims/cache.js.map +1 -1
  161. package/dist/shims/error-boundary.d.ts +1 -1
  162. package/dist/shims/fetch-cache.d.ts +10 -1
  163. package/dist/shims/fetch-cache.js +24 -4
  164. package/dist/shims/fetch-cache.js.map +1 -1
  165. package/dist/shims/font-google-base.d.ts +16 -18
  166. package/dist/shims/font-google-base.js +25 -16
  167. package/dist/shims/font-google-base.js.map +1 -1
  168. package/dist/shims/form.js +1 -1
  169. package/dist/shims/link.js +1 -1
  170. package/dist/shims/navigation.d.ts +7 -3
  171. package/dist/shims/navigation.js +28 -5
  172. package/dist/shims/navigation.js.map +1 -1
  173. package/dist/shims/server.d.ts +2 -0
  174. package/dist/shims/server.js +18 -5
  175. package/dist/shims/server.js.map +1 -1
  176. package/dist/shims/unified-request-context.js +2 -0
  177. package/dist/shims/unified-request-context.js.map +1 -1
  178. package/dist/shims/url-safety.d.ts +3 -1
  179. package/dist/shims/url-safety.js +5 -1
  180. package/dist/shims/url-safety.js.map +1 -1
  181. package/dist/utils/error-cause.d.ts +5 -0
  182. package/dist/utils/error-cause.js +97 -0
  183. package/dist/utils/error-cause.js.map +1 -0
  184. package/dist/utils/lazy-chunks.d.ts +1 -1
  185. package/dist/utils/lazy-chunks.js.map +1 -1
  186. package/package.json +1 -1
  187. package/dist/client/entry.d.ts +0 -1
  188. package/dist/client/entry.js +0 -60
  189. package/dist/client/entry.js.map +0 -1
@@ -21,6 +21,7 @@ const normalizePathModulePath = resolveEntryPath("../server/normalize-path.js",
21
21
  const appRouteHandlerRuntimePath = resolveEntryPath("../server/app-route-handler-runtime.js", import.meta.url);
22
22
  const appRouteHandlerPolicyPath = resolveEntryPath("../server/app-route-handler-policy.js", import.meta.url);
23
23
  const appRouteHandlerExecutionPath = resolveEntryPath("../server/app-route-handler-execution.js", import.meta.url);
24
+ const appServerActionExecutionPath = resolveEntryPath("../server/app-server-action-execution.js", import.meta.url);
24
25
  const appRouteHandlerCachePath = resolveEntryPath("../server/app-route-handler-cache.js", import.meta.url);
25
26
  const appPageCachePath = resolveEntryPath("../server/app-page-cache.js", import.meta.url);
26
27
  const appPageExecutionPath = resolveEntryPath("../server/app-page-execution.js", import.meta.url);
@@ -34,6 +35,7 @@ const appPageRequestPath = resolveEntryPath("../server/app-page-request.js", imp
34
35
  const appRouteHandlerResponsePath = resolveEntryPath("../server/app-route-handler-response.js", import.meta.url);
35
36
  const routeTriePath = resolveEntryPath("../routing/route-trie.js", import.meta.url);
36
37
  const metadataRoutesPath = resolveEntryPath("../server/metadata-routes.js", import.meta.url);
38
+ const errorCausePath = resolveEntryPath("../utils/error-cause.js", import.meta.url);
37
39
  /**
38
40
  * Generate the virtual RSC entry module.
39
41
  *
@@ -87,7 +89,10 @@ function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes, global
87
89
  if (slot.layoutPath) getImportVar(slot.layoutPath);
88
90
  if (slot.loadingPath) getImportVar(slot.loadingPath);
89
91
  if (slot.errorPath) getImportVar(slot.errorPath);
90
- for (const ir of slot.interceptingRoutes) getImportVar(ir.pagePath);
92
+ for (const ir of slot.interceptingRoutes) {
93
+ getImportVar(ir.pagePath);
94
+ for (const layoutPath of ir.layoutPaths) getImportVar(layoutPath);
95
+ }
91
96
  }
92
97
  }
93
98
  const routeEntries = routes.map((route, routeIdx) => {
@@ -98,6 +103,7 @@ function generateRscEntry(appDir, routes, middlewarePath, metadataRoutes, global
98
103
  const interceptEntries = slot.interceptingRoutes.map((ir) => ` {
99
104
  convention: ${JSON.stringify(ir.convention)},
100
105
  targetPattern: ${JSON.stringify(ir.targetPattern)},
106
+ interceptLayouts: [${ir.layoutPaths.map((layoutPath) => getImportVar(layoutPath)).join(", ")}],
101
107
  page: ${getImportVar(ir.pagePath)},
102
108
  params: ${JSON.stringify(ir.params)},
103
109
  }`);
@@ -180,6 +186,7 @@ ${slotEntries.join(",\n")}
180
186
  return `
181
187
  import {
182
188
  renderToReadableStream as _renderToReadableStream,
189
+ decodeAction,
183
190
  decodeReply,
184
191
  loadServerAction,
185
192
  createTemporaryReferenceSet,
@@ -239,6 +246,9 @@ import {
239
246
  import {
240
247
  executeAppRouteHandler as __executeAppRouteHandler,
241
248
  } from ${JSON.stringify(appRouteHandlerExecutionPath)};
249
+ import {
250
+ handleProgressiveServerActionRequest as __handleProgressiveServerActionRequest,
251
+ } from ${JSON.stringify(appServerActionExecutionPath)};
242
252
  import { readAppRouteHandlerCacheResponse as __readAppRouteHandlerCacheResponse } from ${JSON.stringify(appRouteHandlerCachePath)};
243
253
  import { readAppPageCacheResponse as __readAppPageCacheResponse } from ${JSON.stringify(appPageCachePath)};
244
254
  import {
@@ -279,12 +289,13 @@ import {
279
289
  } from ${JSON.stringify(appRouteHandlerResponsePath)};
280
290
  import { _consumeRequestScopedCacheLife, getCacheHandler } from "next/cache";
281
291
  import { getRequestExecutionContext as _getRequestExecutionContext } from ${JSON.stringify(requestContextShimPath)};
282
- import { ensureFetchPatch as _ensureFetchPatch, getCollectedFetchTags } from "vinext/fetch-cache";
292
+ import { ensureFetchPatch as _ensureFetchPatch, getCollectedFetchTags, setCurrentFetchSoftTags } from "vinext/fetch-cache";
283
293
  import { buildRouteTrie as _buildRouteTrie, trieMatch as _trieMatch } from ${JSON.stringify(routeTriePath)};
284
294
  // Import server-only state module to register ALS-backed accessors.
285
295
  import "vinext/navigation-state";
286
296
  import { runWithRequestContext as _runWithUnifiedCtx, createRequestContext as _createUnifiedCtx } from "vinext/unified-request-context";
287
297
  import { reportRequestError as _reportRequestError } from "vinext/instrumentation";
298
+ import { flattenErrorCauses as __flattenErrorCauses } from ${JSON.stringify(errorCausePath)};
288
299
  import { getSSRFontLinks as _getSSRFontLinks, getSSRFontStyles as _getSSRFontStylesGoogle, getSSRFontPreloads as _getSSRFontPreloadsGoogle } from "next/font/google";
289
300
  import { getSSRFontStyles as _getSSRFontStylesLocal, getSSRFontPreloads as _getSSRFontPreloadsLocal } from "next/font/local";
290
301
  function _getSSRFontStyles() { return [..._getSSRFontStylesGoogle(), ..._getSSRFontStylesLocal()]; }
@@ -642,6 +653,7 @@ const rootNotFoundModule = ${rootNotFoundVar ? rootNotFoundVar : "null"};
642
653
  const rootForbiddenModule = ${rootForbiddenVar ? rootForbiddenVar : "null"};
643
654
  const rootUnauthorizedModule = ${rootUnauthorizedVar ? rootUnauthorizedVar : "null"};
644
655
  const rootLayouts = [${rootLayoutVars.join(", ")}];
656
+ const __APP_PAGE_EMPTY_MW_CTX = { headers: null, status: null };
645
657
 
646
658
  /**
647
659
  * Render an HTTP access fallback page (not-found/forbidden/unauthorized) with layouts and noindex meta.
@@ -650,7 +662,7 @@ const rootLayouts = [${rootLayoutVars.join(", ")}];
650
662
  * @param opts.boundaryComponent - Override the boundary component (for layout-level notFound)
651
663
  * @param opts.layouts - Override the layouts to wrap with (for layout-level notFound, excludes the throwing layout)
652
664
  */
653
- async function renderHTTPAccessFallbackPage(route, statusCode, isRscRequest, request, opts, scriptNonce) {
665
+ async function renderHTTPAccessFallbackPage(route, statusCode, isRscRequest, request, opts, scriptNonce, middlewareContext) {
654
666
  return __renderAppPageHttpAccessFallback({
655
667
  boundaryComponent: opts?.boundaryComponent ?? null,
656
668
  buildFontLinkHeader: __buildAppPageFontLinkHeader,
@@ -673,6 +685,7 @@ async function renderHTTPAccessFallbackPage(route, statusCode, isRscRequest, req
673
685
  },
674
686
  makeThenableParams,
675
687
  matchedParams: opts?.matchedParams ?? route?.params ?? {},
688
+ middlewareContext: middlewareContext ?? __APP_PAGE_EMPTY_MW_CTX,
676
689
  requestUrl: request.url,
677
690
  resolveChildSegments: __resolveAppPageChildSegments,
678
691
  rootForbiddenModule: rootForbiddenModule,
@@ -687,8 +700,8 @@ async function renderHTTPAccessFallbackPage(route, statusCode, isRscRequest, req
687
700
  }
688
701
 
689
702
  /** Convenience: render a not-found page (404) */
690
- async function renderNotFoundPage(route, isRscRequest, request, matchedParams, scriptNonce) {
691
- return renderHTTPAccessFallbackPage(route, 404, isRscRequest, request, { matchedParams }, scriptNonce);
703
+ async function renderNotFoundPage(route, isRscRequest, request, matchedParams, scriptNonce, middlewareContext) {
704
+ return renderHTTPAccessFallbackPage(route, 404, isRscRequest, request, { matchedParams }, scriptNonce, middlewareContext);
692
705
  }
693
706
 
694
707
  /**
@@ -698,7 +711,7 @@ async function renderNotFoundPage(route, isRscRequest, request, matchedParams, s
698
711
  * Next.js returns HTTP 200 when error.tsx catches an error (the error is "handled"
699
712
  * by the boundary). This matches that behavior intentionally.
700
713
  */
701
- async function renderErrorBoundaryPage(route, error, isRscRequest, request, matchedParams, scriptNonce) {
714
+ async function renderErrorBoundaryPage(route, error, isRscRequest, request, matchedParams, scriptNonce, middlewareContext) {
702
715
  return __renderAppPageErrorBoundary({
703
716
  buildFontLinkHeader: __buildAppPageFontLinkHeader,
704
717
  clearRequestContext() {
@@ -720,6 +733,7 @@ async function renderErrorBoundaryPage(route, error, isRscRequest, request, matc
720
733
  },
721
734
  makeThenableParams,
722
735
  matchedParams: matchedParams ?? route?.params ?? {},
736
+ middlewareContext: middlewareContext ?? __APP_PAGE_EMPTY_MW_CTX,
723
737
  requestUrl: request.url,
724
738
  resolveChildSegments: __resolveAppPageChildSegments,
725
739
  rootLayouts: rootLayouts,
@@ -790,7 +804,7 @@ function mergeMatchedParams(sourceParams, targetParams) {
790
804
  }
791
805
 
792
806
  // Build a global intercepting route lookup for RSC navigation.
793
- // Maps target URL patterns to { sourceRouteIndex, slotKey, interceptPage, params }.
807
+ // Maps target URL patterns to { sourceRouteIndex, slotKey, interceptPage, interceptLayouts, params }.
794
808
  const interceptLookup = [];
795
809
  for (let ri = 0; ri < routes.length; ri++) {
796
810
  const r = routes[ri];
@@ -803,6 +817,7 @@ for (let ri = 0; ri < routes.length; ri++) {
803
817
  slotKey,
804
818
  targetPattern: intercept.targetPattern,
805
819
  targetPatternParts: intercept.targetPattern.split("/").filter(Boolean),
820
+ interceptLayouts: intercept.interceptLayouts,
806
821
  page: intercept.page,
807
822
  params: intercept.params,
808
823
  });
@@ -986,6 +1001,7 @@ async function buildPageElements(route, params, routePath, pageRequest) {
986
1001
  opts && opts.interceptSlotKey && opts.interceptPage
987
1002
  ? {
988
1003
  [opts.interceptSlotKey]: {
1004
+ layoutModules: opts.interceptLayouts || null,
989
1005
  pageModule: opts.interceptPage,
990
1006
  params: opts.interceptParams || params,
991
1007
  },
@@ -1133,6 +1149,7 @@ export default async function handler(request, ctx) {
1133
1149
  const __uCtx = _createUnifiedCtx({
1134
1150
  headersContext: headersCtx,
1135
1151
  executionContext: ctx ?? _getRequestExecutionContext() ?? null,
1152
+ unstableCacheRevalidation: "background",
1136
1153
  });
1137
1154
  return _runWithUnifiedCtx(__uCtx, async () => {
1138
1155
  _ensureFetchPatch();
@@ -1141,7 +1158,23 @@ export default async function handler(request, ctx) {
1141
1158
  // _handleRequest which fills in .headers and .status;
1142
1159
  // avoids module-level variables that race on Workers.
1143
1160
  const _mwCtx = { headers: null, requestHeaders: null, status: null };
1144
- const response = await _handleRequest(request, __reqCtx, _mwCtx);
1161
+ let response;
1162
+ try {
1163
+ response = await _handleRequest(request, __reqCtx, _mwCtx);
1164
+ } catch (err) {
1165
+ // Dev only: embed err.cause chain into err.message/err.stack so Vite's
1166
+ // dev-server "Internal server error:" logger (which builds output from
1167
+ // message + stack only) reveals the underlying root cause (ECONNREFUSED,
1168
+ // role missing, workerd socket error, etc.) instead of dropping it.
1169
+ // Skipped in production because Node's util.inspect / workerd's logger
1170
+ // already render .cause natively, so flattening would double-print it.
1171
+ // NODE_ENV is build-time-replaced by Vite, so the prod bundle compiles
1172
+ // this branch out entirely.
1173
+ if (process.env.NODE_ENV !== "production") {
1174
+ __flattenErrorCauses(err);
1175
+ }
1176
+ throw err;
1177
+ }
1145
1178
  // Apply custom headers from next.config.js to non-redirect responses.
1146
1179
  // Skip redirects (3xx) because Response.redirect() creates immutable headers,
1147
1180
  // and Next.js doesn't apply custom headers to redirects anyway.
@@ -1585,7 +1618,29 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
1585
1618
  });
1586
1619
 
1587
1620
  // Handle server action POST requests
1588
- const actionId = request.headers.get("x-rsc-action");
1621
+ const actionId = request.headers.get("x-rsc-action") ?? request.headers.get("next-action");
1622
+ const actionContentType = request.headers.get("content-type") || "";
1623
+ const progressiveActionResponse = await __handleProgressiveServerActionRequest({
1624
+ actionId,
1625
+ allowedOrigins: __allowedOrigins,
1626
+ cleanPathname,
1627
+ clearRequestContext() {
1628
+ setHeadersContext(null);
1629
+ setNavigationContext(null);
1630
+ },
1631
+ contentType: actionContentType,
1632
+ decodeAction,
1633
+ getAndClearPendingCookies,
1634
+ getDraftModeCookieHeader,
1635
+ maxActionBodySize: __MAX_ACTION_BODY_SIZE,
1636
+ middlewareHeaders: _mwCtx.headers,
1637
+ readFormDataWithLimit: __readFormDataWithLimit,
1638
+ reportRequestError: _reportRequestError,
1639
+ request,
1640
+ setHeadersAccessPhase,
1641
+ });
1642
+ if (progressiveActionResponse) return progressiveActionResponse;
1643
+
1589
1644
  if (request.method === "POST" && actionId) {
1590
1645
  // ── CSRF protection ─────────────────────────────────────────────────
1591
1646
  // Verify that the Origin header matches the Host header to prevent
@@ -1605,10 +1660,9 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
1605
1660
  }
1606
1661
 
1607
1662
  try {
1608
- const contentType = request.headers.get("content-type") || "";
1609
1663
  let body;
1610
1664
  try {
1611
- body = contentType.startsWith("multipart/form-data")
1665
+ body = actionContentType.startsWith("multipart/form-data")
1612
1666
  ? await __readFormDataWithLimit(request, __MAX_ACTION_BODY_SIZE)
1613
1667
  : await __readBodyWithLimit(request, __MAX_ACTION_BODY_SIZE);
1614
1668
  } catch (sizeErr) {
@@ -1725,6 +1779,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
1725
1779
  toInterceptOpts(intercept) {
1726
1780
  return {
1727
1781
  interceptionContext: interceptionContextHeader,
1782
+ interceptLayouts: intercept.interceptLayouts,
1728
1783
  interceptSlotKey: intercept.slotKey,
1729
1784
  interceptPage: intercept.page,
1730
1785
  interceptParams: intercept.matchedParams,
@@ -1883,14 +1938,17 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
1883
1938
  }
1884
1939
  ` : ""}
1885
1940
  // Render custom not-found page if available, otherwise plain 404
1886
- const notFoundResponse = await renderNotFoundPage(null, isRscRequest, request, undefined, _scriptNonce);
1941
+ const notFoundResponse = await renderNotFoundPage(null, isRscRequest, request, undefined, _scriptNonce, _mwCtx);
1887
1942
  if (notFoundResponse) return notFoundResponse;
1888
1943
  setHeadersContext(null);
1889
1944
  setNavigationContext(null);
1890
- return new Response("Not Found", { status: 404 });
1945
+ const notFoundHeaders = new Headers();
1946
+ __mergeMiddlewareResponseHeaders(notFoundHeaders, _mwCtx.headers);
1947
+ return new Response("Not Found", { status: 404, headers: notFoundHeaders });
1891
1948
  }
1892
1949
 
1893
1950
  const { route, params } = match;
1951
+ setCurrentFetchSoftTags(__pageCacheTags(cleanPathname, []));
1894
1952
 
1895
1953
  // Update navigation context with matched params
1896
1954
  setNavigationContext({
@@ -1974,9 +2032,11 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
1974
2032
  const __revalUCtx = _createUnifiedCtx({
1975
2033
  headersContext: __revalHeadCtx,
1976
2034
  executionContext: _getRequestExecutionContext(),
2035
+ unstableCacheRevalidation: "foreground",
1977
2036
  });
1978
2037
  await _runWithUnifiedCtx(__revalUCtx, async () => {
1979
2038
  _ensureFetchPatch();
2039
+ setCurrentFetchSoftTags(__pageCacheTags(cleanPathname, []));
1980
2040
  await renderFn();
1981
2041
  });
1982
2042
  },
@@ -2124,9 +2184,11 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2124
2184
  const __revalUCtx = _createUnifiedCtx({
2125
2185
  headersContext: __revalHeadCtx,
2126
2186
  executionContext: _getRequestExecutionContext(),
2187
+ unstableCacheRevalidation: "foreground",
2127
2188
  });
2128
2189
  return _runWithUnifiedCtx(__revalUCtx, async () => {
2129
2190
  _ensureFetchPatch();
2191
+ setCurrentFetchSoftTags(__pageCacheTags(cleanPathname, []));
2130
2192
  setNavigationContext({ pathname: cleanPathname, searchParams: new URLSearchParams(), params });
2131
2193
  // Slot context (X-Vinext-Mounted-Slots) is inherited from the
2132
2194
  // triggering request so the regen result is cached under the
@@ -2245,6 +2307,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2245
2307
  toInterceptOpts(intercept) {
2246
2308
  return {
2247
2309
  interceptionContext: interceptionContextHeader,
2310
+ interceptLayouts: intercept.interceptLayouts,
2248
2311
  interceptSlotKey: intercept.slotKey,
2249
2312
  interceptPage: intercept.page,
2250
2313
  interceptParams: intercept.matchedParams,
@@ -2267,7 +2330,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2267
2330
  });
2268
2331
  },
2269
2332
  renderErrorBoundaryPage(buildErr) {
2270
- return renderErrorBoundaryPage(route, buildErr, isRscRequest, request, params, _scriptNonce);
2333
+ return renderErrorBoundaryPage(route, buildErr, isRscRequest, request, params, _scriptNonce, _mwCtx);
2271
2334
  },
2272
2335
  renderSpecialError(__buildSpecialError) {
2273
2336
  return __buildAppPageSpecialErrorResponse({
@@ -2275,6 +2338,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2275
2338
  setHeadersContext(null);
2276
2339
  setNavigationContext(null);
2277
2340
  },
2341
+ middlewareContext: _mwCtx,
2278
2342
  renderFallbackPage(statusCode) {
2279
2343
  return renderHTTPAccessFallbackPage(
2280
2344
  route,
@@ -2285,6 +2349,10 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2285
2349
  matchedParams: params,
2286
2350
  },
2287
2351
  _scriptNonce,
2352
+ // buildAppPageSpecialErrorResponse merges _mwCtx onto this returned
2353
+ // fallback response; keep this inner boundary render unmerged so
2354
+ // additive headers like Set-Cookie and Vary are not duplicated.
2355
+ null,
2288
2356
  );
2289
2357
  },
2290
2358
  requestUrl: request.url,
@@ -2384,7 +2452,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2384
2452
  revalidateSeconds,
2385
2453
  mountedSlotsHeader: __mountedSlotsHeader,
2386
2454
  renderErrorBoundaryResponse(renderErr) {
2387
- return renderErrorBoundaryPage(route, renderErr, isRscRequest, request, params, _scriptNonce);
2455
+ return renderErrorBoundaryPage(route, renderErr, isRscRequest, request, params, _scriptNonce, _mwCtx);
2388
2456
  },
2389
2457
  async renderLayoutSpecialError(__layoutSpecialError, li) {
2390
2458
  return __buildAppPageSpecialErrorResponse({
@@ -2392,6 +2460,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2392
2460
  setHeadersContext(null);
2393
2461
  setNavigationContext(null);
2394
2462
  },
2463
+ middlewareContext: _mwCtx,
2395
2464
  renderFallbackPage(statusCode) {
2396
2465
  // Find the not-found component from the parent level (the boundary that
2397
2466
  // would catch this in Next.js). Walk up from the throwing layout to find
@@ -2418,6 +2487,10 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2418
2487
  matchedParams: params,
2419
2488
  },
2420
2489
  _scriptNonce,
2490
+ // buildAppPageSpecialErrorResponse merges _mwCtx onto this returned
2491
+ // fallback response; keep this inner boundary render unmerged so
2492
+ // additive headers like Set-Cookie and Vary are not duplicated.
2493
+ null,
2421
2494
  );
2422
2495
  },
2423
2496
  requestUrl: request.url,
@@ -2430,6 +2503,7 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2430
2503
  setHeadersContext(null);
2431
2504
  setNavigationContext(null);
2432
2505
  },
2506
+ middlewareContext: _mwCtx,
2433
2507
  renderFallbackPage(statusCode) {
2434
2508
  return renderHTTPAccessFallbackPage(
2435
2509
  route,
@@ -2440,6 +2514,10 @@ async function _handleRequest(request, __reqCtx, _mwCtx) {
2440
2514
  matchedParams: params,
2441
2515
  },
2442
2516
  _scriptNonce,
2517
+ // buildAppPageSpecialErrorResponse merges _mwCtx onto this returned
2518
+ // fallback response; keep this inner boundary render unmerged so
2519
+ // additive headers like Set-Cookie and Vary are not duplicated.
2520
+ null,
2443
2521
  );
2444
2522
  },
2445
2523
  requestUrl: request.url,