qalita 2.5.4__py3-none-any.whl → 2.6.1__py3-none-any.whl
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.
- qalita/_frontend/.next/static/_0oyfpC7N2IGDMa04TT9R/_clientMiddlewareManifest.json +6 -0
- qalita/_frontend/.next/static/chunks/236f7e5abd6f09ff.js +4 -0
- qalita/_frontend/.next/static/chunks/30ea11065999f7ac.js +1 -0
- qalita/_frontend/.next/static/chunks/4dd28bc3f722184a.js +2 -0
- qalita/_frontend/.next/static/chunks/711d597b816a80c1.js +1 -0
- qalita/_frontend/.next/static/chunks/7340adf74ff47ec0.js +1 -0
- qalita/_frontend/.next/static/chunks/a6dad97d9634a72d.js.map +1 -0
- qalita/_frontend/.next/static/chunks/{e393fec0d8ba175d.js → ecf559101be0ae12.js} +3 -3
- qalita/_frontend/.next/static/chunks/turbopack-25186fc8e1264445.js +4 -0
- qalita/_frontend/node_modules/@img/sharp-libvips-linux-x64/versions.json +30 -0
- qalita/_frontend/node_modules/@img/sharp-libvips-linuxmusl-x64/versions.json +30 -0
- qalita/_frontend/node_modules/@next/env/package.json +4 -4
- qalita/_frontend/node_modules/next/dist/build/analyze/index.js +242 -0
- qalita/_frontend/node_modules/next/dist/build/define-env.js +22 -13
- qalita/_frontend/node_modules/next/dist/build/entries.js +5 -5
- qalita/_frontend/node_modules/next/dist/build/generate-routes-manifest.js +91 -0
- qalita/_frontend/node_modules/next/dist/build/index.js +172 -223
- qalita/_frontend/node_modules/next/dist/build/output/log.js +4 -7
- qalita/_frontend/node_modules/next/dist/build/segment-config/app/app-segments.js +23 -99
- qalita/_frontend/node_modules/next/dist/build/segment-config/app/collect-root-param-keys.js +3 -3
- qalita/_frontend/node_modules/next/dist/build/spinner.js +3 -3
- qalita/_frontend/node_modules/next/dist/build/static-paths/app/extract-pathname-route-param-segments-from-loader-tree.js +137 -0
- qalita/_frontend/node_modules/next/dist/build/static-paths/app.js +69 -210
- qalita/_frontend/node_modules/next/dist/build/static-paths/utils.js +83 -11
- qalita/_frontend/node_modules/next/dist/build/swc/index.js +10 -6
- qalita/_frontend/node_modules/next/dist/build/templates/app-page.js +21 -14
- qalita/_frontend/node_modules/next/dist/build/templates/app-route.js +8 -10
- qalita/_frontend/node_modules/next/dist/build/templates/edge-app-route.js +7 -10
- qalita/_frontend/node_modules/next/dist/build/templates/edge-ssr-app.js +16 -20
- qalita/_frontend/node_modules/next/dist/build/templates/edge-ssr.js +20 -14
- qalita/_frontend/node_modules/next/dist/build/templates/edge-wrapper.js +24 -0
- qalita/_frontend/node_modules/next/dist/build/templates/middleware.js +7 -6
- qalita/_frontend/node_modules/next/dist/build/templates/pages-edge-api.js +3 -2
- qalita/_frontend/node_modules/next/dist/build/turbopack-analyze/index.js +116 -0
- qalita/_frontend/node_modules/next/dist/build/turbopack-build/impl.js +2 -1
- qalita/_frontend/node_modules/next/dist/build/type-check.js +7 -8
- qalita/_frontend/node_modules/next/dist/build/utils.js +45 -4
- qalita/_frontend/node_modules/next/dist/build/validate-app-paths.js +242 -0
- qalita/_frontend/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js +20 -2
- qalita/_frontend/node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js +2 -5
- qalita/_frontend/node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js +4 -11
- qalita/_frontend/node_modules/next/dist/build/webpack/loaders/next-root-params-loader.js +1 -1
- qalita/_frontend/node_modules/next/dist/build/webpack/plugins/flight-manifest-plugin.js +1 -1
- qalita/_frontend/node_modules/next/dist/build/webpack/plugins/middleware-plugin.js +3 -0
- qalita/_frontend/node_modules/next/dist/build/webpack-build/impl.js +1 -0
- qalita/_frontend/node_modules/next/dist/build/webpack-config.js +35 -3
- qalita/_frontend/node_modules/next/dist/cli/next-test.js +3 -5
- qalita/_frontend/node_modules/next/dist/client/components/app-router-headers.js +5 -0
- qalita/_frontend/node_modules/next/dist/client/components/app-router-instance.js +3 -11
- qalita/_frontend/node_modules/next/dist/client/components/app-router.js +8 -28
- qalita/_frontend/node_modules/next/dist/client/components/navigation-devtools.js +5 -7
- qalita/_frontend/node_modules/next/dist/client/components/navigation.js +4 -3
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/create-initial-router-state.js +3 -22
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/fetch-server-response.js +6 -18
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/ppr-navigations.js +844 -590
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/hmr-refresh-reducer.js +4 -76
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/navigate-reducer.js +21 -18
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/refresh-reducer.js +48 -85
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/restore-reducer.js +25 -10
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/server-action-reducer.js +126 -113
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/reducers/server-patch-reducer.js +30 -39
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/router-reducer-types.js +0 -1
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/router-reducer.js +2 -2
- qalita/_frontend/node_modules/next/dist/client/components/segment-cache/cache-map.js +13 -18
- qalita/_frontend/node_modules/next/dist/client/components/segment-cache/cache.js +27 -14
- qalita/_frontend/node_modules/next/dist/client/components/segment-cache/lru.js +3 -1
- qalita/_frontend/node_modules/next/dist/client/components/segment-cache/navigation.js +176 -133
- qalita/_frontend/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +12 -12
- qalita/_frontend/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +12 -12
- qalita/_frontend/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +3 -3
- qalita/_frontend/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +10 -10
- qalita/_frontend/node_modules/next/dist/compiled/react-is/package.json +1 -1
- qalita/_frontend/node_modules/next/dist/lib/build-custom-route.js +4 -4
- qalita/_frontend/node_modules/next/dist/lib/constants.js +0 -5
- qalita/_frontend/node_modules/next/dist/lib/default-transpiled-packages.json +1 -0
- qalita/_frontend/node_modules/next/dist/lib/generate-interception-routes-rewrites.js +0 -1
- qalita/_frontend/node_modules/next/dist/lib/helpers/get-npx-command.js +3 -3
- qalita/_frontend/node_modules/next/dist/lib/inline-static-env.js +1 -1
- qalita/_frontend/node_modules/next/dist/lib/known-edge-safe-packages.json +1 -0
- qalita/_frontend/node_modules/next/dist/lib/metadata/metadata.js +17 -11
- qalita/_frontend/node_modules/next/dist/lib/needs-experimental-react.js +2 -2
- qalita/_frontend/node_modules/next/dist/lib/resolve-build-paths.js +44 -76
- qalita/_frontend/node_modules/next/dist/lib/server-external-packages.jsonc +103 -0
- qalita/_frontend/node_modules/next/dist/lib/static-env.js +6 -6
- qalita/_frontend/node_modules/next/dist/lib/turbopack-warning.js +3 -5
- qalita/_frontend/node_modules/next/dist/lib/typescript/runTypeCheck.js +61 -5
- qalita/_frontend/node_modules/next/dist/lib/typescript/type-paths.js +56 -0
- qalita/_frontend/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js +6 -17
- qalita/_frontend/node_modules/next/dist/lib/verify-typescript-setup.js +10 -2
- qalita/_frontend/node_modules/next/dist/lib/worker.js +17 -9
- qalita/_frontend/node_modules/next/dist/server/app-render/action-handler.js +113 -77
- qalita/_frontend/node_modules/next/dist/server/app-render/app-render-prerender-utils.js +36 -15
- qalita/_frontend/node_modules/next/dist/server/app-render/app-render-render-utils.js +36 -15
- qalita/_frontend/node_modules/next/dist/server/app-render/app-render-scheduling.js +188 -0
- qalita/_frontend/node_modules/next/dist/server/app-render/app-render.js +804 -748
- qalita/_frontend/node_modules/next/dist/server/app-render/collect-segment-data.js +8 -2
- qalita/_frontend/node_modules/next/dist/server/app-render/create-component-styles-and-scripts.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/app-render/create-error-handler.js +42 -75
- qalita/_frontend/node_modules/next/dist/server/app-render/dynamic-rendering.js +127 -14
- qalita/_frontend/node_modules/next/dist/server/app-render/encryption-utils.js +3 -108
- qalita/_frontend/node_modules/next/dist/server/app-render/encryption.js +4 -3
- qalita/_frontend/node_modules/next/dist/server/app-render/flight-render-result.js +3 -2
- qalita/_frontend/node_modules/next/dist/server/app-render/get-css-inlined-link-tags.js +9 -8
- qalita/_frontend/node_modules/next/dist/server/app-render/get-layer-assets.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/app-render/manifests-singleton.js +257 -0
- qalita/_frontend/node_modules/next/dist/server/app-render/prospective-render-utils.js +25 -8
- qalita/_frontend/node_modules/next/dist/server/app-render/staged-rendering.js +161 -15
- qalita/_frontend/node_modules/next/dist/server/app-render/use-flight-response.js +67 -20
- qalita/_frontend/node_modules/next/dist/server/app-render/walk-tree-with-flight-router-state.js +2 -2
- qalita/_frontend/node_modules/next/dist/server/async-storage/work-store.js +2 -1
- qalita/_frontend/node_modules/next/dist/server/base-server.js +32 -23
- qalita/_frontend/node_modules/next/dist/server/capsize-font-metrics.json +181516 -0
- qalita/_frontend/node_modules/next/dist/server/config-schema.js +8 -1
- qalita/_frontend/node_modules/next/dist/server/config-shared.js +83 -2
- qalita/_frontend/node_modules/next/dist/server/config.js +24 -17
- qalita/_frontend/node_modules/next/dist/server/dev/hot-reloader-rspack.js +171 -0
- qalita/_frontend/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +37 -25
- qalita/_frontend/node_modules/next/dist/server/dev/hot-reloader-types.js +1 -0
- qalita/_frontend/node_modules/next/dist/server/dev/hot-reloader-webpack.js +62 -57
- qalita/_frontend/node_modules/next/dist/server/dev/log-requests.js +11 -3
- qalita/_frontend/node_modules/next/dist/server/dev/messages.js +10 -0
- qalita/_frontend/node_modules/next/dist/server/dev/serialized-errors.js +67 -0
- qalita/_frontend/node_modules/next/dist/server/dev/static-paths-worker.js +10 -0
- qalita/_frontend/node_modules/next/dist/server/lib/app-info-log.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/lib/chrome-devtools-workspace.js +2 -2
- qalita/_frontend/node_modules/next/dist/server/lib/dev-bundler-service.js +6 -10
- qalita/_frontend/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js +4 -4
- qalita/_frontend/node_modules/next/dist/server/lib/lazy-result.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/lib/patch-fetch.js +9 -9
- qalita/_frontend/node_modules/next/dist/server/lib/router-server.js +43 -29
- qalita/_frontend/node_modules/next/dist/server/lib/router-utils/build-prefetch-segment-data-route.js +0 -21
- qalita/_frontend/node_modules/next/dist/server/lib/router-utils/filesystem.js +2 -7
- qalita/_frontend/node_modules/next/dist/server/lib/router-utils/resolve-routes.js +8 -4
- qalita/_frontend/node_modules/next/dist/server/lib/start-server.js +3 -3
- qalita/_frontend/node_modules/next/dist/server/lib/trace/tracer.js +4 -0
- qalita/_frontend/node_modules/next/dist/server/load-components.js +3 -9
- qalita/_frontend/node_modules/next/dist/server/next-server.js +19 -18
- qalita/_frontend/node_modules/next/dist/server/next.js +1 -1
- qalita/_frontend/node_modules/next/dist/server/node-environment-extensions/fast-set-immediate.external.js +570 -0
- qalita/_frontend/node_modules/next/dist/server/node-environment-extensions/utils.js +60 -3
- qalita/_frontend/node_modules/next/dist/server/node-environment.js +1 -0
- qalita/_frontend/node_modules/next/dist/server/patch-error-inspect.js +7 -4
- qalita/_frontend/node_modules/next/dist/server/request/fallback-params.js +23 -66
- qalita/_frontend/node_modules/next/dist/server/route-modules/app-route/module.js +2 -2
- qalita/_frontend/node_modules/next/dist/server/route-modules/pages/pages-handler.js +6 -3
- qalita/_frontend/node_modules/next/dist/server/route-modules/route-module.js +79 -18
- qalita/_frontend/node_modules/next/dist/server/stream-utils/node-web-streams-helper.js +28 -4
- qalita/_frontend/node_modules/next/dist/server/typescript/rules/config.js +50 -6
- qalita/_frontend/node_modules/next/dist/server/use-cache/use-cache-wrapper.js +68 -23
- qalita/_frontend/node_modules/next/dist/server/web/edge-route-module-wrapper.js +7 -5
- qalita/_frontend/node_modules/next/dist/server/web/sandbox/context.js +8 -9
- qalita/_frontend/node_modules/next/dist/server/web/spec-extension/adapters/request-cookies.js +2 -1
- qalita/_frontend/node_modules/next/dist/server/web/spec-extension/revalidate.js +7 -3
- qalita/_frontend/node_modules/next/dist/shared/lib/action-revalidation-kind.js +31 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/constants.js +6 -1
- qalita/_frontend/node_modules/next/dist/shared/lib/deployment-id.js +36 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- qalita/_frontend/node_modules/next/dist/shared/lib/hooks-client-context.shared-runtime.js +5 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/router/routes/app.js +122 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/router/utils/get-dynamic-param.js +20 -49
- qalita/_frontend/node_modules/next/dist/shared/lib/router/utils/get-segment-param.js +6 -6
- qalita/_frontend/node_modules/next/dist/shared/lib/router/utils/interception-prefix-from-param-type.js +33 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/router/utils/resolve-param-value.js +116 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/segment-cache/output-export-prefetch-encoding.js +3 -24
- qalita/_frontend/node_modules/next/dist/shared/lib/segment.js +5 -0
- qalita/_frontend/node_modules/next/dist/shared/lib/turbopack/utils.js +6 -5
- qalita/_frontend/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
- qalita/_frontend/node_modules/next/dist/telemetry/events/build.js +11 -0
- qalita/_frontend/node_modules/next/dist/telemetry/events/version.js +2 -2
- qalita/_frontend/node_modules/next/package.json +20 -18
- qalita/_frontend/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/typesMap.json +497 -0
- qalita/_frontend/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
- qalita/_frontend/package.json +3 -3
- qalita/_frontend/server.js +1 -1
- qalita/commands/pack.py +3 -3
- qalita/commands/source.py +1 -1
- qalita/internal/utils.py +11 -7
- qalita/web/app.py +20 -4
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/METADATA +1 -1
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/RECORD +197 -168
- qalita/_frontend/.next/static/chunks/023d923a37d494fc.js +0 -1
- qalita/_frontend/.next/static/chunks/247eb132b7f7b574.js +0 -1
- qalita/_frontend/.next/static/chunks/bba035711c7e37a2.js +0 -4
- qalita/_frontend/.next/static/chunks/c903f9580a4b6572.js +0 -2
- qalita/_frontend/.next/static/chunks/cbd55ab9639e1e66.js +0 -1
- qalita/_frontend/.next/static/chunks/turbopack-1ad58da399056f41.js +0 -3
- qalita/_frontend/node_modules/next/dist/build/deployment-id.js +0 -18
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/apply-flight-data.js +0 -53
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/apply-router-state-patch-to-tree.js +0 -105
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/fill-cache-with-new-subtree-data.js +0 -110
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.js +0 -131
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/handle-segment-mismatch.js +0 -25
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/invalidate-cache-by-router-state.js +0 -32
- qalita/_frontend/node_modules/next/dist/client/components/router-reducer/refetch-inactive-parallel-segments.js +0 -104
- qalita/_frontend/node_modules/next/dist/server/app-render/action-utils.js +0 -90
- qalita/_frontend/node_modules/next/dist/server/normalizers/request/prefetch-rsc.js +0 -31
- /qalita/_frontend/.next/static/{X4_AlYMbCyee-ZVLjCYMg → _0oyfpC7N2IGDMa04TT9R}/_buildManifest.js +0 -0
- /qalita/_frontend/.next/static/{X4_AlYMbCyee-ZVLjCYMg → _0oyfpC7N2IGDMa04TT9R}/_ssgManifest.js +0 -0
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/WHEEL +0 -0
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/entry_points.txt +0 -0
- {qalita-2.5.4.dist-info → qalita-2.6.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -42,7 +42,7 @@ const _makegetserverinsertedhtml = require("./make-get-server-inserted-html");
|
|
|
42
42
|
const _walktreewithflightrouterstate = require("./walk-tree-with-flight-router-state");
|
|
43
43
|
const _createcomponenttree = require("./create-component-tree");
|
|
44
44
|
const _getassetquerystring = require("./get-asset-query-string");
|
|
45
|
-
const
|
|
45
|
+
const _manifestssingleton = require("./manifests-singleton");
|
|
46
46
|
const _postponedstate = require("./postponed-state");
|
|
47
47
|
const _hooksservercontext = require("../../client/components/hooks-server-context");
|
|
48
48
|
const _useflightresponse = require("./use-flight-response");
|
|
@@ -50,7 +50,6 @@ const _staticgenerationbailout = require("../../client/components/static-generat
|
|
|
50
50
|
const _formatservererror = require("../../lib/format-server-error");
|
|
51
51
|
const _dynamicrendering = require("./dynamic-rendering");
|
|
52
52
|
const _clientcomponentrendererlogger = require("../client-component-renderer-logger");
|
|
53
|
-
const _actionutils = require("./action-utils");
|
|
54
53
|
const _helpers = require("../base-http/helpers");
|
|
55
54
|
const _parserelativeurl = require("../../shared/lib/router/utils/parse-relative-url");
|
|
56
55
|
const _approuter = /*#__PURE__*/ _interop_require_default(require("../../client/components/app-router"));
|
|
@@ -208,8 +207,8 @@ function createNotFoundLoaderTree(loaderTree) {
|
|
|
208
207
|
if (!segmentParam) {
|
|
209
208
|
return null;
|
|
210
209
|
}
|
|
211
|
-
const segmentKey = segmentParam.
|
|
212
|
-
const dynamicParamType = _getshortdynamicparamtype.dynamicParamTypes[segmentParam.
|
|
210
|
+
const segmentKey = segmentParam.paramName;
|
|
211
|
+
const dynamicParamType = _getshortdynamicparamtype.dynamicParamTypes[segmentParam.paramType];
|
|
213
212
|
return (0, _getdynamicparam.getDynamicParam)(interpolatedParams, segmentKey, dynamicParamType, fallbackRouteParams);
|
|
214
213
|
};
|
|
215
214
|
}
|
|
@@ -240,7 +239,7 @@ function NonIndex({ createElement, pagePath, statusCode, isPossibleServerAction
|
|
|
240
239
|
let flightData = '';
|
|
241
240
|
const { componentMod: { routeModule: { userland: { loaderTree } }, createElement, createMetadataComponents, Fragment }, getDynamicParamFromSegment, query, requestId, flightRouterState, workStore, url } = ctx;
|
|
242
241
|
const serveStreamingMetadata = !!ctx.renderOpts.serveStreamingMetadata;
|
|
243
|
-
if (!(options == null ? void 0 : options.
|
|
242
|
+
if (!(options == null ? void 0 : options.skipPageRendering)) {
|
|
244
243
|
const preloadCallbacks = [];
|
|
245
244
|
const { Viewport, Metadata, MetadataOutlet } = createMetadataComponents({
|
|
246
245
|
tree: loaderTree,
|
|
@@ -278,6 +277,8 @@ function NonIndex({ createElement, pagePath, statusCode, isPossibleServerAction
|
|
|
278
277
|
})).map((path)=>path.slice(1)) // remove the '' (root) segment
|
|
279
278
|
;
|
|
280
279
|
}
|
|
280
|
+
const varyHeader = ctx.res.getHeader('vary');
|
|
281
|
+
const couldBeIntercepted = typeof varyHeader === 'string' && varyHeader.includes(_approuterheaders.NEXT_URL);
|
|
281
282
|
// If we have an action result, then this is a server action response.
|
|
282
283
|
// We can rely on this because `ActionResult` will always be a promise, even if
|
|
283
284
|
// the result is falsey.
|
|
@@ -285,13 +286,17 @@ function NonIndex({ createElement, pagePath, statusCode, isPossibleServerAction
|
|
|
285
286
|
return {
|
|
286
287
|
a: options.actionResult,
|
|
287
288
|
f: flightData,
|
|
288
|
-
b: ctx.sharedContext.buildId
|
|
289
|
+
b: ctx.sharedContext.buildId,
|
|
290
|
+
q: getRenderedSearch(query),
|
|
291
|
+
i: !!couldBeIntercepted
|
|
289
292
|
};
|
|
290
293
|
}
|
|
291
294
|
// Otherwise, it's a regular RSC response.
|
|
292
295
|
const baseResponse = {
|
|
293
296
|
b: ctx.sharedContext.buildId,
|
|
294
297
|
f: flightData,
|
|
298
|
+
q: getRenderedSearch(query),
|
|
299
|
+
i: !!couldBeIntercepted,
|
|
295
300
|
S: workStore.isStaticGeneration
|
|
296
301
|
};
|
|
297
302
|
// For runtime prefetches, we encode the stale time and isPartial flag in the response body
|
|
@@ -321,20 +326,21 @@ function createErrorContext(ctx, renderSource) {
|
|
|
321
326
|
* Produces a RenderResult containing the Flight data for the given request. See
|
|
322
327
|
* `generateDynamicRSCPayload` for information on the contents of the render result.
|
|
323
328
|
*/ async function generateDynamicFlightRenderResult(req, ctx, requestStore, options) {
|
|
324
|
-
const {
|
|
325
|
-
const { dev = false, onInstrumentationRequestError, setReactDebugChannel } = renderOpts;
|
|
326
|
-
function onFlightDataRenderError(err) {
|
|
327
|
-
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, createErrorContext(ctx, 'react-server-components-payload'));
|
|
329
|
+
const { componentMod: { renderToReadableStream }, htmlRequestId, renderOpts, requestId, workStore } = ctx;
|
|
330
|
+
const { dev = false, onInstrumentationRequestError, setReactDebugChannel, nextExport = false } = renderOpts;
|
|
331
|
+
function onFlightDataRenderError(err, silenceLog) {
|
|
332
|
+
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, createErrorContext(ctx, 'react-server-components-payload'), silenceLog);
|
|
328
333
|
}
|
|
329
|
-
const onError = (0, _createerrorhandler.
|
|
334
|
+
const onError = (0, _createerrorhandler.createReactServerErrorHandler)(dev, nextExport, workStore.reactServerErrorsByDigest, onFlightDataRenderError);
|
|
330
335
|
const debugChannel = setReactDebugChannel && createDebugChannel();
|
|
331
336
|
if (debugChannel) {
|
|
332
337
|
setReactDebugChannel(debugChannel.clientSide, htmlRequestId, requestId);
|
|
333
338
|
}
|
|
339
|
+
const { clientModules } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
334
340
|
// For app dir, use the bundled version of Flight server renderer (renderToReadableStream)
|
|
335
341
|
// which contains the subset React.
|
|
336
342
|
const rscPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, generateDynamicRSCPayload, ctx, options);
|
|
337
|
-
const flightReadableStream = _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, renderToReadableStream, rscPayload,
|
|
343
|
+
const flightReadableStream = _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, renderToReadableStream, rscPayload, clientModules, {
|
|
338
344
|
onError,
|
|
339
345
|
temporaryReferences: options == null ? void 0 : options.temporaryReferences,
|
|
340
346
|
filterStackFrame,
|
|
@@ -342,23 +348,31 @@ function createErrorContext(ctx, renderSource) {
|
|
|
342
348
|
});
|
|
343
349
|
return new _flightrenderresult.FlightRenderResult(flightReadableStream, {
|
|
344
350
|
fetchMetrics: workStore.fetchMetrics
|
|
345
|
-
});
|
|
351
|
+
}, options == null ? void 0 : options.waitUntil);
|
|
346
352
|
}
|
|
347
|
-
async function stagedRenderToReadableStreamWithoutCachesInDev(ctx, requestStore, getPayload,
|
|
353
|
+
async function stagedRenderToReadableStreamWithoutCachesInDev(ctx, requestStore, getPayload, options) {
|
|
348
354
|
const { componentMod: { renderToReadableStream } } = ctx;
|
|
349
355
|
// We're rendering while bypassing caches,
|
|
350
356
|
// so we have no hope of showing a useful runtime stage.
|
|
351
357
|
// But we still want things like `params` to show up in devtools correctly,
|
|
352
358
|
// which relies on mechanisms we've set up for staged rendering,
|
|
353
359
|
// so we do a 2-task version (Static -> Dynamic) instead.
|
|
354
|
-
|
|
360
|
+
// We aren't doing any validation in this kind of render so we say there
|
|
361
|
+
// is not runtime prefetch regardless of whether there is or not
|
|
362
|
+
const hasRuntimePrefetch = false;
|
|
363
|
+
// We aren't filling caches so we don't need to abort this render, it'll
|
|
364
|
+
// stream in a single pass
|
|
365
|
+
const abortSignal = null;
|
|
366
|
+
const stageController = new _stagedrendering.StagedRenderingController(abortSignal, hasRuntimePrefetch);
|
|
355
367
|
const environmentName = ()=>{
|
|
356
368
|
const currentStage = stageController.currentStage;
|
|
357
369
|
switch(currentStage){
|
|
370
|
+
case _stagedrendering.RenderStage.Before:
|
|
358
371
|
case _stagedrendering.RenderStage.Static:
|
|
359
372
|
return 'Prerender';
|
|
360
373
|
case _stagedrendering.RenderStage.Runtime:
|
|
361
374
|
case _stagedrendering.RenderStage.Dynamic:
|
|
375
|
+
case _stagedrendering.RenderStage.Abandoned:
|
|
362
376
|
return 'Server';
|
|
363
377
|
default:
|
|
364
378
|
currentStage;
|
|
@@ -371,9 +385,11 @@ async function stagedRenderToReadableStreamWithoutCachesInDev(ctx, requestStore,
|
|
|
371
385
|
};
|
|
372
386
|
requestStore.stagedRendering = stageController;
|
|
373
387
|
requestStore.asyncApiPromises = createAsyncApiPromisesInDev(stageController, requestStore.cookies, requestStore.mutableCookies, requestStore.headers);
|
|
388
|
+
const { clientModules } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
374
389
|
const rscPayload = await getPayload(requestStore);
|
|
375
390
|
return await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, _apprenderrenderutils.scheduleInSequentialTasks, ()=>{
|
|
376
|
-
|
|
391
|
+
stageController.advanceStage(_stagedrendering.RenderStage.Static);
|
|
392
|
+
return renderToReadableStream(rscPayload, clientModules, {
|
|
377
393
|
...options,
|
|
378
394
|
environmentName
|
|
379
395
|
});
|
|
@@ -384,13 +400,16 @@ async function stagedRenderToReadableStreamWithoutCachesInDev(ctx, requestStore,
|
|
|
384
400
|
/**
|
|
385
401
|
* Fork of `generateDynamicFlightRenderResult` that renders using `renderWithRestartOnCacheMissInDev`
|
|
386
402
|
* to ensure correct separation of environments Prerender/Server (for use in Cache Components)
|
|
387
|
-
*/ async function generateDynamicFlightRenderResultWithStagesInDev(req, ctx, initialRequestStore, createRequestStore) {
|
|
388
|
-
const { htmlRequestId, renderOpts, requestId, workStore, componentMod: { createElement } } = ctx;
|
|
389
|
-
const { dev = false, onInstrumentationRequestError, setReactDebugChannel, setCacheStatus,
|
|
390
|
-
function onFlightDataRenderError(err) {
|
|
391
|
-
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, createErrorContext(ctx, 'react-server-components-payload'));
|
|
403
|
+
*/ async function generateDynamicFlightRenderResultWithStagesInDev(req, ctx, initialRequestStore, createRequestStore, devFallbackParams) {
|
|
404
|
+
const { htmlRequestId, renderOpts, requestId, workStore, componentMod: { createElement }, url } = ctx;
|
|
405
|
+
const { dev = false, onInstrumentationRequestError, setReactDebugChannel, setCacheStatus, nextExport = false } = renderOpts;
|
|
406
|
+
function onFlightDataRenderError(err, silenceLog) {
|
|
407
|
+
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, createErrorContext(ctx, 'react-server-components-payload'), silenceLog);
|
|
392
408
|
}
|
|
393
|
-
const onError = (0, _createerrorhandler.
|
|
409
|
+
const onError = (0, _createerrorhandler.createReactServerErrorHandler)(dev, nextExport, workStore.reactServerErrorsByDigest, onFlightDataRenderError);
|
|
410
|
+
// We only validate RSC requests if it is for HMR refreshes since we know we
|
|
411
|
+
// will render all the layouts necessary to perform the validation.
|
|
412
|
+
const shouldValidate = !isBypassingCachesInDev(renderOpts, initialRequestStore) && initialRequestStore.isHmrRefresh === true;
|
|
394
413
|
const getPayload = async (requestStore)=>{
|
|
395
414
|
const payload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, generateDynamicRSCPayload, ctx, undefined);
|
|
396
415
|
if (isBypassingCachesInDev(renderOpts, requestStore)) {
|
|
@@ -399,6 +418,10 @@ async function stagedRenderToReadableStreamWithoutCachesInDev(ctx, requestStore,
|
|
|
399
418
|
payload._bypassCachesInDev = createElement(WarnForBypassCachesInDev, {
|
|
400
419
|
route: workStore.route
|
|
401
420
|
});
|
|
421
|
+
} else if (shouldValidate) {
|
|
422
|
+
// If this payload will be used for validation, it needs to contain the
|
|
423
|
+
// canonical URL. Without it we'd get an error.
|
|
424
|
+
payload.c = prepareInitialCanonicalUrl(url);
|
|
402
425
|
}
|
|
403
426
|
return payload;
|
|
404
427
|
};
|
|
@@ -414,19 +437,29 @@ async function stagedRenderToReadableStreamWithoutCachesInDev(ctx, requestStore,
|
|
|
414
437
|
if (setCacheStatus) {
|
|
415
438
|
setCacheStatus('ready', htmlRequestId);
|
|
416
439
|
}
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
440
|
+
const { stream: serverStream, accumulatedChunksPromise, staticInterruptReason, runtimeInterruptReason, staticStageEndTime, runtimeStageEndTime, debugChannel: returnedDebugChannel, requestStore: finalRequestStore } = await renderWithRestartOnCacheMissInDev(ctx, initialRequestStore, createRequestStore, getPayload, onError);
|
|
441
|
+
if (shouldValidate) {
|
|
442
|
+
let validationDebugChannelClient = undefined;
|
|
443
|
+
if (returnedDebugChannel) {
|
|
444
|
+
const [t1, t2] = returnedDebugChannel.clientSide.readable.tee();
|
|
445
|
+
returnedDebugChannel.clientSide.readable = t1;
|
|
446
|
+
validationDebugChannelClient = nodeStreamFromReadableStream(t2);
|
|
447
|
+
}
|
|
448
|
+
_consoleasyncstorageexternal.consoleAsyncStorage.run({
|
|
449
|
+
dim: true
|
|
450
|
+
}, spawnStaticShellValidationInDev, accumulatedChunksPromise, staticInterruptReason, runtimeInterruptReason, staticStageEndTime, runtimeStageEndTime, ctx, finalRequestStore, devFallbackParams, validationDebugChannelClient);
|
|
451
|
+
}
|
|
452
|
+
debugChannel = returnedDebugChannel;
|
|
453
|
+
stream = serverStream;
|
|
420
454
|
} else {
|
|
421
455
|
// We're either bypassing caches or we can't restart the render.
|
|
422
456
|
// Do a dynamic render, but with (basic) environment labels.
|
|
423
|
-
assertClientReferenceManifest(clientReferenceManifest);
|
|
424
457
|
// Set cache status to bypass when specifically bypassing caches in dev
|
|
425
458
|
if (setCacheStatus) {
|
|
426
459
|
setCacheStatus('bypass', htmlRequestId);
|
|
427
460
|
}
|
|
428
461
|
debugChannel = setReactDebugChannel && createDebugChannel();
|
|
429
|
-
stream = await stagedRenderToReadableStreamWithoutCachesInDev(ctx, initialRequestStore, getPayload,
|
|
462
|
+
stream = await stagedRenderToReadableStreamWithoutCachesInDev(ctx, initialRequestStore, getPayload, {
|
|
430
463
|
onError: onError,
|
|
431
464
|
filterStackFrame,
|
|
432
465
|
debugChannel: debugChannel == null ? void 0 : debugChannel.serverSide
|
|
@@ -440,13 +473,13 @@ async function stagedRenderToReadableStreamWithoutCachesInDev(ctx, requestStore,
|
|
|
440
473
|
});
|
|
441
474
|
}
|
|
442
475
|
async function generateRuntimePrefetchResult(req, ctx, requestStore) {
|
|
443
|
-
const { workStore } = ctx;
|
|
444
|
-
const
|
|
445
|
-
function onFlightDataRenderError(err) {
|
|
446
|
-
return
|
|
447
|
-
createErrorContext(ctx, 'react-server-components-payload'));
|
|
476
|
+
const { workStore, renderOpts } = ctx;
|
|
477
|
+
const { nextExport = false, onInstrumentationRequestError } = renderOpts;
|
|
478
|
+
function onFlightDataRenderError(err, silenceLog) {
|
|
479
|
+
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, // TODO(runtime-ppr): should we use a different value?
|
|
480
|
+
createErrorContext(ctx, 'react-server-components-payload'), silenceLog);
|
|
448
481
|
}
|
|
449
|
-
const onError = (0, _createerrorhandler.
|
|
482
|
+
const onError = (0, _createerrorhandler.createReactServerErrorHandler)(false, nextExport, workStore.reactServerErrorsByDigest, onFlightDataRenderError);
|
|
450
483
|
const metadata = {};
|
|
451
484
|
// Generate a random sentinel that will be used as a placeholder in the payload
|
|
452
485
|
// and later replaced by the transform stream
|
|
@@ -469,8 +502,7 @@ async function generateRuntimePrefetchResult(req, ctx, requestStore) {
|
|
|
469
502
|
}
|
|
470
503
|
async function prospectiveRuntimeServerPrerender(ctx, getPayload, prerenderResumeDataCache, renderResumeDataCache, rootParams, headers, cookies, draftMode) {
|
|
471
504
|
const { implicitTags, renderOpts, workStore } = ctx;
|
|
472
|
-
const {
|
|
473
|
-
assertClientReferenceManifest(clientReferenceManifest);
|
|
505
|
+
const { ComponentMod } = renderOpts;
|
|
474
506
|
// Prerender controller represents the lifetime of the prerender.
|
|
475
507
|
// It will be aborted when a Task is complete or a synchronously aborting
|
|
476
508
|
// API is called. Notably during cache-filling renders this does not actually
|
|
@@ -514,10 +546,11 @@ async function prospectiveRuntimeServerPrerender(ctx, getPayload, prerenderResum
|
|
|
514
546
|
cookies,
|
|
515
547
|
draftMode
|
|
516
548
|
};
|
|
549
|
+
const { clientModules } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
517
550
|
// We're not going to use the result of this render because the only time it could be used
|
|
518
551
|
// is if it completes in a microtask and that's likely very rare for any non-trivial app
|
|
519
552
|
const initialServerPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(initialServerPrerenderStore, getPayload);
|
|
520
|
-
const pendingInitialServerResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(initialServerPrerenderStore, ComponentMod.prerender, initialServerPayload,
|
|
553
|
+
const pendingInitialServerResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(initialServerPrerenderStore, ComponentMod.prerender, initialServerPayload, clientModules, {
|
|
521
554
|
filterStackFrame,
|
|
522
555
|
onError: (err)=>{
|
|
523
556
|
const digest = (0, _createerrorhandler.getDigestForWellKnownError)(err);
|
|
@@ -529,7 +562,7 @@ async function prospectiveRuntimeServerPrerender(ctx, getPayload, prerenderResum
|
|
|
529
562
|
// the error is caused by unfinished components within the render
|
|
530
563
|
return;
|
|
531
564
|
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
532
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
565
|
+
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
|
|
533
566
|
}
|
|
534
567
|
},
|
|
535
568
|
// We don't want to stop rendering until the cacheSignal is complete so we pass
|
|
@@ -555,7 +588,7 @@ async function prospectiveRuntimeServerPrerender(ctx, getPayload, prerenderResum
|
|
|
555
588
|
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
556
589
|
// We don't normally log these errors because we are going to retry anyway but
|
|
557
590
|
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
558
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
591
|
+
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
|
|
559
592
|
}
|
|
560
593
|
return null;
|
|
561
594
|
}
|
|
@@ -650,8 +683,7 @@ async function prospectiveRuntimeServerPrerender(ctx, getPayload, prerenderResum
|
|
|
650
683
|
}
|
|
651
684
|
async function finalRuntimeServerPrerender(ctx, getPayload, prerenderResumeDataCache, renderResumeDataCache, rootParams, headers, cookies, draftMode, onError, runtimePrefetchSentinel) {
|
|
652
685
|
const { implicitTags, renderOpts } = ctx;
|
|
653
|
-
const {
|
|
654
|
-
assertClientReferenceManifest(clientReferenceManifest);
|
|
686
|
+
const { ComponentMod, experimental, isDebugDynamicAccesses } = renderOpts;
|
|
655
687
|
const selectStaleTime = createSelectStaleTime(experimental);
|
|
656
688
|
let serverIsDynamic = false;
|
|
657
689
|
const finalServerController = new AbortController();
|
|
@@ -685,11 +717,12 @@ async function finalRuntimeServerPrerender(ctx, getPayload, prerenderResumeDataC
|
|
|
685
717
|
cookies,
|
|
686
718
|
draftMode
|
|
687
719
|
};
|
|
720
|
+
const { clientModules } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
688
721
|
const finalRSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(finalServerPrerenderStore, getPayload);
|
|
689
722
|
let prerenderIsPending = true;
|
|
690
723
|
const result = await (0, _apprenderprerenderutils.prerenderAndAbortInSequentialTasksWithStages)(async ()=>{
|
|
691
724
|
// Static stage
|
|
692
|
-
const prerenderResult = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(finalServerPrerenderStore, ComponentMod.prerender, finalRSCPayload,
|
|
725
|
+
const prerenderResult = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(finalServerPrerenderStore, ComponentMod.prerender, finalRSCPayload, clientModules, {
|
|
693
726
|
filterStackFrame,
|
|
694
727
|
onError,
|
|
695
728
|
signal: finalServerController.signal
|
|
@@ -944,19 +977,10 @@ async function getErrorRSCPayload(tree, ctx, ssrError, errorType) {
|
|
|
944
977
|
S: workStore.isStaticGeneration
|
|
945
978
|
};
|
|
946
979
|
}
|
|
947
|
-
function assertClientReferenceManifest(clientReferenceManifest) {
|
|
948
|
-
if (!clientReferenceManifest) {
|
|
949
|
-
throw Object.defineProperty(new _invarianterror.InvariantError('Expected clientReferenceManifest to be defined.'), "__NEXT_ERROR_CODE", {
|
|
950
|
-
value: "E692",
|
|
951
|
-
enumerable: false,
|
|
952
|
-
configurable: true
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
980
|
// This component must run in an SSR context. It will render the RSC root component
|
|
957
|
-
function App({ reactServerStream, reactDebugStream,
|
|
981
|
+
function App({ reactServerStream, reactDebugStream, debugEndTime, preinitScripts, ServerInsertedHTMLProvider, nonce, images }) {
|
|
958
982
|
preinitScripts();
|
|
959
|
-
const response = _react.use((0, _useflightresponse.
|
|
983
|
+
const response = _react.use((0, _useflightresponse.getFlightStream)(reactServerStream, reactDebugStream, debugEndTime, nonce));
|
|
960
984
|
const initialState = (0, _createinitialrouterstate.createInitialRouterState)({
|
|
961
985
|
// This is not used during hydration, so we don't have to pass a
|
|
962
986
|
// real timestamp.
|
|
@@ -964,7 +988,6 @@ function App({ reactServerStream, reactDebugStream, preinitScripts, clientRefere
|
|
|
964
988
|
initialFlightData: response.f,
|
|
965
989
|
initialCanonicalUrlParts: response.c,
|
|
966
990
|
initialRenderedSearch: response.q,
|
|
967
|
-
initialParallelRoutes: new Map(),
|
|
968
991
|
// location is not initialized in the SSR render
|
|
969
992
|
// it's set to window.location during hydration
|
|
970
993
|
location: null
|
|
@@ -990,9 +1013,9 @@ function App({ reactServerStream, reactDebugStream, preinitScripts, clientRefere
|
|
|
990
1013
|
// @TODO our error stream should be probably just use the same root component. But it was previously
|
|
991
1014
|
// different I don't want to figure out if that is meaningful at this time so just keeping the behavior
|
|
992
1015
|
// consistent for now.
|
|
993
|
-
function ErrorApp({ reactServerStream,
|
|
1016
|
+
function ErrorApp({ reactServerStream, preinitScripts, ServerInsertedHTMLProvider, nonce, images }) {
|
|
994
1017
|
/* eslint-disable @next/internal/no-ambiguous-jsx -- React Client */ preinitScripts();
|
|
995
|
-
const response = _react.use((0, _useflightresponse.
|
|
1018
|
+
const response = _react.use((0, _useflightresponse.getFlightStream)(reactServerStream, undefined, undefined, nonce));
|
|
996
1019
|
const initialState = (0, _createinitialrouterstate.createInitialRouterState)({
|
|
997
1020
|
// This is not used during hydration, so we don't have to pass a
|
|
998
1021
|
// real timestamp.
|
|
@@ -1000,7 +1023,6 @@ function ErrorApp({ reactServerStream, reactDebugStream, preinitScripts, clientR
|
|
|
1000
1023
|
initialFlightData: response.f,
|
|
1001
1024
|
initialCanonicalUrlParts: response.c,
|
|
1002
1025
|
initialRenderedSearch: response.q,
|
|
1003
|
-
initialParallelRoutes: new Map(),
|
|
1004
1026
|
// location is not initialized in the SSR render
|
|
1005
1027
|
// it's set to window.location during hydration
|
|
1006
1028
|
location: null
|
|
@@ -1026,7 +1048,7 @@ async function renderToHTMLOrFlightImpl(req, res, url, pagePath, query, renderOp
|
|
|
1026
1048
|
// avoid that resources can be deduped by React Float if the same resource is
|
|
1027
1049
|
// rendered or preloaded multiple times: `<link href="a.css?v={Date.now()}"/>`.
|
|
1028
1050
|
const requestTimestamp = Date.now();
|
|
1029
|
-
const {
|
|
1051
|
+
const { ComponentMod, nextFontManifest, serverActions, assetPrefix = '', enableTainting, cacheComponents } = renderOpts;
|
|
1030
1052
|
// We need to expose the bundled `require` API globally for
|
|
1031
1053
|
// react-server-dom-webpack. This is a hack until we find a better way.
|
|
1032
1054
|
if (ComponentMod.__next_app__) {
|
|
@@ -1117,16 +1139,6 @@ async function renderToHTMLOrFlightImpl(req, res, url, pagePath, query, renderOp
|
|
|
1117
1139
|
statusCode: isNotFoundPath ? 404 : undefined
|
|
1118
1140
|
};
|
|
1119
1141
|
const appUsingSizeAdjustment = !!(nextFontManifest == null ? void 0 : nextFontManifest.appUsingSizeAdjust);
|
|
1120
|
-
assertClientReferenceManifest(clientReferenceManifest);
|
|
1121
|
-
const serverModuleMap = (0, _actionutils.createServerModuleMap)({
|
|
1122
|
-
serverActionsManifest
|
|
1123
|
-
});
|
|
1124
|
-
(0, _encryptionutils.setReferenceManifestsSingleton)({
|
|
1125
|
-
page: workStore.page,
|
|
1126
|
-
clientReferenceManifest,
|
|
1127
|
-
serverActionsManifest,
|
|
1128
|
-
serverModuleMap
|
|
1129
|
-
});
|
|
1130
1142
|
ComponentMod.patchFetch();
|
|
1131
1143
|
// Pull out the hooks/references from the component.
|
|
1132
1144
|
const { routeModule: { userland: { loaderTree } }, taintObjectReference } = ComponentMod;
|
|
@@ -1182,7 +1194,6 @@ async function renderToHTMLOrFlightImpl(req, res, url, pagePath, query, renderOp
|
|
|
1182
1194
|
requestId,
|
|
1183
1195
|
htmlRequestId,
|
|
1184
1196
|
pagePath,
|
|
1185
|
-
clientReferenceManifest,
|
|
1186
1197
|
assetPrefix,
|
|
1187
1198
|
isNotFoundPath,
|
|
1188
1199
|
nonce,
|
|
@@ -1271,18 +1282,12 @@ async function renderToHTMLOrFlightImpl(req, res, url, pagePath, query, renderOp
|
|
|
1271
1282
|
return generateRuntimePrefetchResult(req, ctx, requestStore);
|
|
1272
1283
|
} else {
|
|
1273
1284
|
if (process.env.NODE_ENV === 'development' && process.env.NEXT_RUNTIME !== 'edge' && cacheComponents) {
|
|
1274
|
-
return generateDynamicFlightRenderResultWithStagesInDev(req, ctx, requestStore, createRequestStore);
|
|
1285
|
+
return generateDynamicFlightRenderResultWithStagesInDev(req, ctx, requestStore, createRequestStore, devFallbackParams);
|
|
1275
1286
|
} else {
|
|
1276
1287
|
return generateDynamicFlightRenderResult(req, ctx, requestStore);
|
|
1277
1288
|
}
|
|
1278
1289
|
}
|
|
1279
1290
|
}
|
|
1280
|
-
const renderToStreamWithTracing = (0, _tracer.getTracer)().wrap(_constants.AppRenderSpan.getBodyResult, {
|
|
1281
|
-
spanName: `render route (app) ${pagePath}`,
|
|
1282
|
-
attributes: {
|
|
1283
|
-
'next.route': pagePath
|
|
1284
|
-
}
|
|
1285
|
-
}, renderToStream);
|
|
1286
1291
|
let didExecuteServerAction = false;
|
|
1287
1292
|
let formState = null;
|
|
1288
1293
|
if (isPossibleActionRequest) {
|
|
@@ -1293,7 +1298,6 @@ async function renderToHTMLOrFlightImpl(req, res, url, pagePath, query, renderOp
|
|
|
1293
1298
|
req,
|
|
1294
1299
|
res,
|
|
1295
1300
|
ComponentMod,
|
|
1296
|
-
serverModuleMap,
|
|
1297
1301
|
generateFlight: generateDynamicFlightRenderResult,
|
|
1298
1302
|
workStore,
|
|
1299
1303
|
requestStore,
|
|
@@ -1306,7 +1310,7 @@ async function renderToHTMLOrFlightImpl(req, res, url, pagePath, query, renderOp
|
|
|
1306
1310
|
const notFoundLoaderTree = createNotFoundLoaderTree(loaderTree);
|
|
1307
1311
|
res.statusCode = 404;
|
|
1308
1312
|
metadata.statusCode = 404;
|
|
1309
|
-
const stream = await
|
|
1313
|
+
const stream = await renderToStream(requestStore, req, res, ctx, notFoundLoaderTree, formState, postponedState, metadata, undefined, devFallbackParams);
|
|
1310
1314
|
return new _renderresult.default(stream, {
|
|
1311
1315
|
metadata,
|
|
1312
1316
|
contentType: _constants1.HTML_CONTENT_TYPE_HEADER
|
|
@@ -1328,7 +1332,7 @@ async function renderToHTMLOrFlightImpl(req, res, url, pagePath, query, renderOp
|
|
|
1328
1332
|
metadata,
|
|
1329
1333
|
contentType: _constants1.HTML_CONTENT_TYPE_HEADER
|
|
1330
1334
|
};
|
|
1331
|
-
const stream = await
|
|
1335
|
+
const stream = await renderToStream(// NOTE: in Cache Components (dev), if the render is restarted, it will use a different requestStore
|
|
1332
1336
|
// than the one that we're passing in here.
|
|
1333
1337
|
requestStore, req, res, ctx, loaderTree, formState, postponedState, metadata, // If we're rendering HTML after an action, we don't want restartable-render behavior
|
|
1334
1338
|
// because the result should be dynamic, like it is in prod.
|
|
@@ -1445,8 +1449,7 @@ function applyMetadataFromPrerenderResult(response, metadata, workStore) {
|
|
|
1445
1449
|
}
|
|
1446
1450
|
async function renderToStream(requestStore, req, res, ctx, tree, formState, postponedState, metadata, createRequestStore, devFallbackParams) {
|
|
1447
1451
|
/* eslint-disable @next/internal/no-ambiguous-jsx -- React Client */ const { assetPrefix, htmlRequestId, nonce, pagePath, renderOpts, requestId, workStore } = ctx;
|
|
1448
|
-
const { basePath, buildManifest,
|
|
1449
|
-
assertClientReferenceManifest(clientReferenceManifest);
|
|
1452
|
+
const { basePath, buildManifest, ComponentMod: { createElement, renderToReadableStream: serverRenderToReadableStream }, crossOrigin, dev = false, experimental, nextExport = false, onInstrumentationRequestError, page, reactMaxHeadersLength, setReactDebugChannel, shouldWaitOnAllReady, subresourceIntegrityManifest, supportsDynamicResponse, cacheComponents } = renderOpts;
|
|
1450
1453
|
const { ServerInsertedHTMLProvider, renderServerInsertedHTML } = (0, _serverinsertedhtml.createServerInsertedHTML)();
|
|
1451
1454
|
const getServerInsertedMetadata = (0, _createserverinsertedmetadata.createServerInsertedMetadata)(nonce);
|
|
1452
1455
|
const tracingMetadata = (0, _utils1.getTracedMetadata)((0, _tracer.getTracer)().getTracePropagationData(), experimental.clientTraceMetadata);
|
|
@@ -1463,272 +1466,216 @@ async function renderToStream(requestStore, req, res, ctx, tree, formState, post
|
|
|
1463
1466
|
// In development mode, set the request ID as a global variable, before the
|
|
1464
1467
|
// bootstrap script is executed, which depends on it during hydration.
|
|
1465
1468
|
const bootstrapScriptContent = process.env.NODE_ENV !== 'production' ? `self.__next_r=${JSON.stringify(requestId)}` : undefined;
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
function
|
|
1469
|
-
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1469
|
+
// Create the "render route (app)" span manually so we can keep it open during streaming.
|
|
1470
|
+
// This is necessary because errors inside Suspense boundaries are reported asynchronously
|
|
1471
|
+
// during stream consumption, after a typical wrapped function would have ended the span.
|
|
1472
|
+
// Note: We pass the full span name as the first argument since startSpan uses it directly.
|
|
1473
|
+
const renderSpan = (0, _tracer.getTracer)().startSpan(`render route (app) ${pagePath}`, {
|
|
1474
|
+
attributes: {
|
|
1475
|
+
'next.span_name': `render route (app) ${pagePath}`,
|
|
1476
|
+
'next.span_type': _constants.AppRenderSpan.getBodyResult,
|
|
1477
|
+
'next.route': pagePath
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1480
|
+
// Helper to end the span with error status (used when throwing from catch blocks)
|
|
1481
|
+
const endSpanWithError = (err)=>{
|
|
1482
|
+
if (!renderSpan.isRecording()) return;
|
|
1483
|
+
if (err instanceof Error) {
|
|
1484
|
+
renderSpan.recordException(err);
|
|
1485
|
+
renderSpan.setAttribute('error.type', err.name);
|
|
1486
|
+
}
|
|
1487
|
+
renderSpan.setStatus({
|
|
1488
|
+
code: _tracer.SpanStatusCode.ERROR,
|
|
1489
|
+
message: err instanceof Error ? err.message : undefined
|
|
1490
|
+
});
|
|
1491
|
+
renderSpan.end();
|
|
1492
|
+
};
|
|
1493
|
+
// Run the rest of the function within the span's context so child spans
|
|
1494
|
+
// (like "build component tree", "generateMetadata") are properly parented.
|
|
1495
|
+
return (0, _tracer.getTracer)().withSpan(renderSpan, async ()=>{
|
|
1496
|
+
const { reactServerErrorsByDigest } = workStore;
|
|
1497
|
+
function onHTMLRenderRSCError(err, silenceLog) {
|
|
1498
|
+
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, createErrorContext(ctx, 'react-server-components'), silenceLog);
|
|
1499
|
+
}
|
|
1500
|
+
const serverComponentsErrorHandler = (0, _createerrorhandler.createReactServerErrorHandler)(dev, nextExport, reactServerErrorsByDigest, onHTMLRenderRSCError, renderSpan);
|
|
1501
|
+
function onHTMLRenderSSRError(err) {
|
|
1502
|
+
// We don't need to silence logs here. onHTMLRenderSSRError won't be called
|
|
1503
|
+
// at all if the error was logged before in the RSC error handler.
|
|
1504
|
+
const silenceLog = false;
|
|
1505
|
+
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, createErrorContext(ctx, 'server-rendering'), silenceLog);
|
|
1506
|
+
}
|
|
1507
|
+
const allCapturedErrors = [];
|
|
1508
|
+
const htmlRendererErrorHandler = (0, _createerrorhandler.createHTMLErrorHandler)(dev, nextExport, reactServerErrorsByDigest, allCapturedErrors, onHTMLRenderSSRError, renderSpan);
|
|
1509
|
+
let reactServerResult = null;
|
|
1510
|
+
let reactDebugStream;
|
|
1511
|
+
const setHeader = res.setHeader.bind(res);
|
|
1512
|
+
const appendHeader = res.appendHeader.bind(res);
|
|
1513
|
+
const { clientModules } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
1514
|
+
try {
|
|
1515
|
+
if (// We only want this behavior when we have React's dev builds available
|
|
1516
|
+
process.env.NODE_ENV === 'development' && // We only want this behavior when running `next dev`
|
|
1517
|
+
dev && // Edge routes never prerender so we don't have a Prerender environment for anything in edge runtime
|
|
1518
|
+
process.env.NEXT_RUNTIME !== 'edge' && // We only have a Prerender environment for projects opted into cacheComponents
|
|
1519
|
+
cacheComponents) {
|
|
1520
|
+
let debugChannel;
|
|
1521
|
+
const getPayload = async (// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1522
|
+
requestStore)=>{
|
|
1523
|
+
const payload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, getRSCPayload, tree, ctx, res.statusCode === 404);
|
|
1524
|
+
if (isBypassingCachesInDev(renderOpts, requestStore)) {
|
|
1525
|
+
// Mark the RSC payload to indicate that caches were bypassed in dev.
|
|
1526
|
+
// This lets the client know not to cache anything based on this render.
|
|
1527
|
+
if (renderOpts.setCacheStatus) {
|
|
1528
|
+
// we know this is available when cacheComponents is enabled, but typeguard to be safe
|
|
1529
|
+
renderOpts.setCacheStatus('bypass', htmlRequestId);
|
|
1530
|
+
}
|
|
1531
|
+
payload._bypassCachesInDev = createElement(WarnForBypassCachesInDev, {
|
|
1532
|
+
route: workStore.route
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
return payload;
|
|
1536
|
+
};
|
|
1537
|
+
if (// We only do this flow if we can safely recreate the store from scratch
|
|
1538
|
+
// (which is not the case for renders after an action)
|
|
1539
|
+
createRequestStore && // We only do this flow if we're not bypassing caches in dev using
|
|
1540
|
+
// "disable cache" in devtools or a hard refresh (cache-control: "no-store")
|
|
1541
|
+
!isBypassingCachesInDev(renderOpts, requestStore)) {
|
|
1542
|
+
const { stream: serverStream, accumulatedChunksPromise, staticInterruptReason, runtimeInterruptReason, staticStageEndTime, runtimeStageEndTime, debugChannel: returnedDebugChannel, requestStore: finalRequestStore } = await renderWithRestartOnCacheMissInDev(ctx, requestStore, createRequestStore, getPayload, serverComponentsErrorHandler);
|
|
1543
|
+
let validationDebugChannelClient = undefined;
|
|
1544
|
+
if (returnedDebugChannel) {
|
|
1545
|
+
const [t1, t2] = returnedDebugChannel.clientSide.readable.tee();
|
|
1546
|
+
returnedDebugChannel.clientSide.readable = t1;
|
|
1547
|
+
validationDebugChannelClient = nodeStreamFromReadableStream(t2);
|
|
1503
1548
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1549
|
+
_consoleasyncstorageexternal.consoleAsyncStorage.run({
|
|
1550
|
+
dim: true
|
|
1551
|
+
}, spawnStaticShellValidationInDev, accumulatedChunksPromise, staticInterruptReason, runtimeInterruptReason, staticStageEndTime, runtimeStageEndTime, ctx, finalRequestStore, devFallbackParams, validationDebugChannelClient);
|
|
1552
|
+
reactServerResult = new _apprenderprerenderutils.ReactServerResult(serverStream);
|
|
1553
|
+
requestStore = finalRequestStore;
|
|
1554
|
+
debugChannel = returnedDebugChannel;
|
|
1555
|
+
} else {
|
|
1556
|
+
// We're either bypassing caches or we can't restart the render.
|
|
1557
|
+
// Do a dynamic render, but with (basic) environment labels.
|
|
1558
|
+
debugChannel = setReactDebugChannel && createDebugChannel();
|
|
1559
|
+
const serverStream = await stagedRenderToReadableStreamWithoutCachesInDev(ctx, requestStore, getPayload, {
|
|
1560
|
+
onError: serverComponentsErrorHandler,
|
|
1561
|
+
filterStackFrame,
|
|
1562
|
+
debugChannel: debugChannel == null ? void 0 : debugChannel.serverSide
|
|
1506
1563
|
});
|
|
1564
|
+
reactServerResult = new _apprenderprerenderutils.ReactServerResult(serverStream);
|
|
1565
|
+
}
|
|
1566
|
+
if (debugChannel && setReactDebugChannel) {
|
|
1567
|
+
const [readableSsr, readableBrowser] = debugChannel.clientSide.readable.tee();
|
|
1568
|
+
reactDebugStream = readableSsr;
|
|
1569
|
+
setReactDebugChannel({
|
|
1570
|
+
readable: readableBrowser
|
|
1571
|
+
}, htmlRequestId, requestId);
|
|
1507
1572
|
}
|
|
1508
|
-
return payload;
|
|
1509
|
-
};
|
|
1510
|
-
if (// We only do this flow if we can safely recreate the store from scratch
|
|
1511
|
-
// (which is not the case for renders after an action)
|
|
1512
|
-
createRequestStore && // We only do this flow if we're not bypassing caches in dev using
|
|
1513
|
-
// "disable cache" in devtools or a hard refresh (cache-control: "no-store")
|
|
1514
|
-
!isBypassingCachesInDev(renderOpts, requestStore)) {
|
|
1515
|
-
const { stream: serverStream, debugChannel: returnedDebugChannel, requestStore: finalRequestStore } = await renderWithRestartOnCacheMissInDev(ctx, requestStore, createRequestStore, getPayload, serverComponentsErrorHandler);
|
|
1516
|
-
reactServerResult = new _apprenderprerenderutils.ReactServerResult(serverStream);
|
|
1517
|
-
requestStore = finalRequestStore;
|
|
1518
|
-
debugChannel = returnedDebugChannel;
|
|
1519
1573
|
} else {
|
|
1520
|
-
// We'
|
|
1521
|
-
|
|
1522
|
-
debugChannel = setReactDebugChannel && createDebugChannel();
|
|
1523
|
-
|
|
1524
|
-
|
|
1574
|
+
// This is a dynamic render. We don't do dynamic tracking because we're not prerendering
|
|
1575
|
+
const RSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, getRSCPayload, tree, ctx, res.statusCode === 404);
|
|
1576
|
+
const debugChannel = setReactDebugChannel && createDebugChannel();
|
|
1577
|
+
if (debugChannel) {
|
|
1578
|
+
const [readableSsr, readableBrowser] = debugChannel.clientSide.readable.tee();
|
|
1579
|
+
reactDebugStream = readableSsr;
|
|
1580
|
+
setReactDebugChannel({
|
|
1581
|
+
readable: readableBrowser
|
|
1582
|
+
}, htmlRequestId, requestId);
|
|
1583
|
+
}
|
|
1584
|
+
reactServerResult = new _apprenderprerenderutils.ReactServerResult(_workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, serverRenderToReadableStream, RSCPayload, clientModules, {
|
|
1525
1585
|
filterStackFrame,
|
|
1586
|
+
onError: serverComponentsErrorHandler,
|
|
1526
1587
|
debugChannel: debugChannel == null ? void 0 : debugChannel.serverSide
|
|
1527
|
-
});
|
|
1528
|
-
reactServerResult = new _apprenderprerenderutils.ReactServerResult(serverStream);
|
|
1529
|
-
}
|
|
1530
|
-
if (debugChannel && setReactDebugChannel) {
|
|
1531
|
-
const [readableSsr, readableBrowser] = debugChannel.clientSide.readable.tee();
|
|
1532
|
-
reactDebugStream = readableSsr;
|
|
1533
|
-
setReactDebugChannel({
|
|
1534
|
-
readable: readableBrowser
|
|
1535
|
-
}, htmlRequestId, requestId);
|
|
1536
|
-
}
|
|
1537
|
-
// TODO(restart-on-cache-miss):
|
|
1538
|
-
// This can probably be optimized to do less work,
|
|
1539
|
-
// because we've already made sure that we have warm caches.
|
|
1540
|
-
_consoleasyncstorageexternal.consoleAsyncStorage.run({
|
|
1541
|
-
dim: true
|
|
1542
|
-
}, spawnDynamicValidationInDev, resolveValidation, tree, ctx, res.statusCode === 404, clientReferenceManifest, requestStore, devFallbackParams);
|
|
1543
|
-
} else {
|
|
1544
|
-
// This is a dynamic render. We don't do dynamic tracking because we're not prerendering
|
|
1545
|
-
const RSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, getRSCPayload, tree, ctx, res.statusCode === 404);
|
|
1546
|
-
const debugChannel = setReactDebugChannel && createDebugChannel();
|
|
1547
|
-
if (debugChannel) {
|
|
1548
|
-
const [readableSsr, readableBrowser] = debugChannel.clientSide.readable.tee();
|
|
1549
|
-
reactDebugStream = readableSsr;
|
|
1550
|
-
setReactDebugChannel({
|
|
1551
|
-
readable: readableBrowser
|
|
1552
|
-
}, htmlRequestId, requestId);
|
|
1588
|
+
}));
|
|
1553
1589
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
// This is a regular dynamic render
|
|
1609
|
-
const renderToReadableStream = require('react-dom/server').renderToReadableStream;
|
|
1610
|
-
const htmlStream = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, renderToReadableStream, /*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
1611
|
-
reactServerStream: reactServerResult.tee(),
|
|
1612
|
-
reactDebugStream: reactDebugStream,
|
|
1613
|
-
preinitScripts: preinitScripts,
|
|
1614
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
1615
|
-
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
1616
|
-
nonce: nonce,
|
|
1617
|
-
images: ctx.renderOpts.images
|
|
1618
|
-
}), {
|
|
1619
|
-
onError: htmlRendererErrorHandler,
|
|
1620
|
-
nonce,
|
|
1621
|
-
onHeaders: (headers)=>{
|
|
1622
|
-
headers.forEach((value, key)=>{
|
|
1623
|
-
appendHeader(key, value);
|
|
1624
|
-
});
|
|
1625
|
-
},
|
|
1626
|
-
maxHeadersLength: reactMaxHeadersLength,
|
|
1627
|
-
bootstrapScriptContent,
|
|
1628
|
-
bootstrapScripts: [
|
|
1629
|
-
bootstrapScript
|
|
1630
|
-
],
|
|
1631
|
-
formState
|
|
1632
|
-
});
|
|
1633
|
-
const getServerInsertedHTML = (0, _makegetserverinsertedhtml.makeGetServerInsertedHTML)({
|
|
1634
|
-
polyfills,
|
|
1635
|
-
renderServerInsertedHTML,
|
|
1636
|
-
serverCapturedErrors: allCapturedErrors,
|
|
1637
|
-
basePath,
|
|
1638
|
-
tracingMetadata: tracingMetadata
|
|
1639
|
-
});
|
|
1640
|
-
/**
|
|
1641
|
-
* Rules of Static & Dynamic HTML:
|
|
1642
|
-
*
|
|
1643
|
-
* 1.) We must generate static HTML unless the caller explicitly opts
|
|
1644
|
-
* in to dynamic HTML support.
|
|
1645
|
-
*
|
|
1646
|
-
* 2.) If dynamic HTML support is requested, we must honor that request
|
|
1647
|
-
* or throw an error. It is the sole responsibility of the caller to
|
|
1648
|
-
* ensure they aren't e.g. requesting dynamic HTML for a static page.
|
|
1649
|
-
*
|
|
1650
|
-
* 3.) If `shouldWaitOnAllReady` is true, which indicates we need to
|
|
1651
|
-
* resolve all suspenses and generate a full HTML. e.g. when it's a
|
|
1652
|
-
* html limited bot requests, we produce the full HTML content.
|
|
1653
|
-
*
|
|
1654
|
-
* These rules help ensure that other existing features like request caching,
|
|
1655
|
-
* coalescing, and ISR continue working as intended.
|
|
1656
|
-
*/ const generateStaticHTML = supportsDynamicResponse !== true || !!shouldWaitOnAllReady;
|
|
1657
|
-
return await (0, _nodewebstreamshelper.continueFizzStream)(htmlStream, {
|
|
1658
|
-
inlinedDataStream: (0, _useflightresponse.createInlinedDataReadableStream)(reactServerResult.consume(), nonce, formState),
|
|
1659
|
-
isStaticGeneration: generateStaticHTML,
|
|
1660
|
-
isBuildTimePrerendering: ctx.workStore.isBuildTimePrerendering === true,
|
|
1661
|
-
buildId: ctx.workStore.buildId,
|
|
1662
|
-
getServerInsertedHTML,
|
|
1663
|
-
getServerInsertedMetadata,
|
|
1664
|
-
validateRootLayout: dev
|
|
1665
|
-
});
|
|
1666
|
-
} catch (err) {
|
|
1667
|
-
if ((0, _staticgenerationbailout.isStaticGenBailoutError)(err) || typeof err === 'object' && err !== null && 'message' in err && typeof err.message === 'string' && err.message.includes('https://nextjs.org/docs/advanced-features/static-html-export')) {
|
|
1668
|
-
// Ensure that "next dev" prints the red error overlay
|
|
1669
|
-
throw err;
|
|
1670
|
-
}
|
|
1671
|
-
// If a bailout made it to this point, it means it wasn't wrapped inside
|
|
1672
|
-
// a suspense boundary.
|
|
1673
|
-
const shouldBailoutToCSR = (0, _bailouttocsr.isBailoutToCSRError)(err);
|
|
1674
|
-
if (shouldBailoutToCSR) {
|
|
1675
|
-
const stack = (0, _formatservererror.getStackWithoutErrorMessage)(err);
|
|
1676
|
-
(0, _log.error)(`${err.reason} should be wrapped in a suspense boundary at page "${pagePath}". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\n${stack}`);
|
|
1677
|
-
throw err;
|
|
1678
|
-
}
|
|
1679
|
-
let errorType;
|
|
1680
|
-
if ((0, _httpaccessfallback.isHTTPAccessFallbackError)(err)) {
|
|
1681
|
-
res.statusCode = (0, _httpaccessfallback.getAccessFallbackHTTPStatus)(err);
|
|
1682
|
-
metadata.statusCode = res.statusCode;
|
|
1683
|
-
errorType = (0, _httpaccessfallback.getAccessFallbackErrorTypeByStatus)(res.statusCode);
|
|
1684
|
-
} else if ((0, _redirecterror.isRedirectError)(err)) {
|
|
1685
|
-
errorType = 'redirect';
|
|
1686
|
-
res.statusCode = (0, _redirect.getRedirectStatusCodeFromError)(err);
|
|
1687
|
-
metadata.statusCode = res.statusCode;
|
|
1688
|
-
const redirectUrl = (0, _addpathprefix.addPathPrefix)((0, _redirect.getURLFromRedirectError)(err), basePath);
|
|
1689
|
-
// If there were mutable cookies set, we need to set them on the
|
|
1690
|
-
// response.
|
|
1691
|
-
const headers = new Headers();
|
|
1692
|
-
if ((0, _requestcookies.appendMutableCookies)(headers, requestStore.mutableCookies)) {
|
|
1693
|
-
setHeader('set-cookie', Array.from(headers.values()));
|
|
1694
|
-
}
|
|
1695
|
-
setHeader('location', redirectUrl);
|
|
1696
|
-
} else if (!shouldBailoutToCSR) {
|
|
1697
|
-
res.statusCode = 500;
|
|
1698
|
-
metadata.statusCode = res.statusCode;
|
|
1699
|
-
}
|
|
1700
|
-
const [errorPreinitScripts, errorBootstrapScript] = (0, _requiredscripts.getRequiredScripts)(buildManifest, assetPrefix, crossOrigin, subresourceIntegrityManifest, (0, _getassetquerystring.getAssetQueryString)(ctx, false), nonce, '/_not-found/page');
|
|
1701
|
-
const errorRSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, getErrorRSCPayload, tree, ctx, reactServerErrorsByDigest.has(err.digest) ? null : err, errorType);
|
|
1702
|
-
const errorServerStream = _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, serverRenderToReadableStream, errorRSCPayload, clientReferenceManifest.clientModules, {
|
|
1703
|
-
filterStackFrame,
|
|
1704
|
-
onError: serverComponentsErrorHandler
|
|
1705
|
-
});
|
|
1706
|
-
if (reactServerResult === null) {
|
|
1707
|
-
// We errored when we did not have an RSC stream to read from. This is not just a render
|
|
1708
|
-
// error, we need to throw early
|
|
1709
|
-
throw err;
|
|
1710
|
-
}
|
|
1711
|
-
try {
|
|
1712
|
-
const fizzStream = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, _nodewebstreamshelper.renderToInitialFizzStream, {
|
|
1713
|
-
ReactDOMServer: require('react-dom/server'),
|
|
1714
|
-
element: /*#__PURE__*/ (0, _jsxruntime.jsx)(ErrorApp, {
|
|
1715
|
-
reactServerStream: errorServerStream,
|
|
1716
|
-
reactDebugStream: undefined,
|
|
1717
|
-
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
1718
|
-
preinitScripts: errorPreinitScripts,
|
|
1719
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
1720
|
-
nonce: nonce,
|
|
1721
|
-
images: ctx.renderOpts.images
|
|
1722
|
-
}),
|
|
1723
|
-
streamOptions: {
|
|
1724
|
-
nonce,
|
|
1725
|
-
bootstrapScriptContent,
|
|
1726
|
-
// Include hydration scripts in the HTML
|
|
1727
|
-
bootstrapScripts: [
|
|
1728
|
-
errorBootstrapScript
|
|
1729
|
-
],
|
|
1730
|
-
formState
|
|
1590
|
+
// React doesn't start rendering synchronously but we want the RSC render to have a chance to start
|
|
1591
|
+
// before we begin SSR rendering because we want to capture any available preload headers so we tick
|
|
1592
|
+
// one task before continuing
|
|
1593
|
+
await (0, _scheduler.waitAtLeastOneReactRenderTask)();
|
|
1594
|
+
// If provided, the postpone state should be parsed as JSON so it can be
|
|
1595
|
+
// provided to React.
|
|
1596
|
+
if (typeof renderOpts.postponed === 'string') {
|
|
1597
|
+
if ((postponedState == null ? void 0 : postponedState.type) === _postponedstate.DynamicState.DATA) {
|
|
1598
|
+
// We have a complete HTML Document in the prerender but we need to
|
|
1599
|
+
// still include the new server component render because it was not included
|
|
1600
|
+
// in the static prelude.
|
|
1601
|
+
const inlinedReactServerDataStream = (0, _useflightresponse.createInlinedDataReadableStream)(reactServerResult.tee(), nonce, formState);
|
|
1602
|
+
// End the span since there's no async rendering in this path
|
|
1603
|
+
if (renderSpan.isRecording()) renderSpan.end();
|
|
1604
|
+
return (0, _nodewebstreamshelper.chainStreams)(inlinedReactServerDataStream, (0, _nodewebstreamshelper.createDocumentClosingStream)());
|
|
1605
|
+
} else if (postponedState) {
|
|
1606
|
+
// We assume we have dynamic HTML requiring a resume render to complete
|
|
1607
|
+
const { postponed, preludeState } = (0, _postponedstate.getPostponedFromState)(postponedState);
|
|
1608
|
+
const resume = require('react-dom/server').resume;
|
|
1609
|
+
const htmlStream = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, resume, /*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
1610
|
+
reactServerStream: reactServerResult.tee(),
|
|
1611
|
+
reactDebugStream: reactDebugStream,
|
|
1612
|
+
debugEndTime: undefined,
|
|
1613
|
+
preinitScripts: preinitScripts,
|
|
1614
|
+
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
1615
|
+
nonce: nonce,
|
|
1616
|
+
images: ctx.renderOpts.images
|
|
1617
|
+
}), postponed, {
|
|
1618
|
+
onError: htmlRendererErrorHandler,
|
|
1619
|
+
nonce
|
|
1620
|
+
});
|
|
1621
|
+
// End the render span only after React completed rendering (including anything inside Suspense boundaries)
|
|
1622
|
+
htmlStream.allReady.finally(()=>{
|
|
1623
|
+
if (renderSpan.isRecording()) renderSpan.end();
|
|
1624
|
+
});
|
|
1625
|
+
const getServerInsertedHTML = (0, _makegetserverinsertedhtml.makeGetServerInsertedHTML)({
|
|
1626
|
+
polyfills,
|
|
1627
|
+
renderServerInsertedHTML,
|
|
1628
|
+
serverCapturedErrors: allCapturedErrors,
|
|
1629
|
+
basePath,
|
|
1630
|
+
tracingMetadata: tracingMetadata
|
|
1631
|
+
});
|
|
1632
|
+
return await (0, _nodewebstreamshelper.continueDynamicHTMLResume)(htmlStream, {
|
|
1633
|
+
// If the prelude is empty (i.e. is no static shell), we should wait for initial HTML to be rendered
|
|
1634
|
+
// to avoid injecting RSC data too early.
|
|
1635
|
+
// If we have a non-empty-prelude (i.e. a static HTML shell), then it's already been sent separately,
|
|
1636
|
+
// so we shouldn't wait for any HTML to be emitted from the resume before sending RSC data.
|
|
1637
|
+
delayDataUntilFirstHtmlChunk: preludeState === _postponedstate.DynamicHTMLPreludeState.Empty,
|
|
1638
|
+
inlinedDataStream: (0, _useflightresponse.createInlinedDataReadableStream)(reactServerResult.consume(), nonce, formState),
|
|
1639
|
+
getServerInsertedHTML,
|
|
1640
|
+
getServerInsertedMetadata
|
|
1641
|
+
});
|
|
1731
1642
|
}
|
|
1643
|
+
}
|
|
1644
|
+
// This is a regular dynamic render
|
|
1645
|
+
const renderToReadableStream = require('react-dom/server').renderToReadableStream;
|
|
1646
|
+
const htmlStream = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, renderToReadableStream, /*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
1647
|
+
reactServerStream: reactServerResult.tee(),
|
|
1648
|
+
reactDebugStream: reactDebugStream,
|
|
1649
|
+
debugEndTime: undefined,
|
|
1650
|
+
preinitScripts: preinitScripts,
|
|
1651
|
+
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
1652
|
+
nonce: nonce,
|
|
1653
|
+
images: ctx.renderOpts.images
|
|
1654
|
+
}), {
|
|
1655
|
+
onError: htmlRendererErrorHandler,
|
|
1656
|
+
nonce,
|
|
1657
|
+
onHeaders: (headers)=>{
|
|
1658
|
+
headers.forEach((value, key)=>{
|
|
1659
|
+
appendHeader(key, value);
|
|
1660
|
+
});
|
|
1661
|
+
},
|
|
1662
|
+
maxHeadersLength: reactMaxHeadersLength,
|
|
1663
|
+
bootstrapScriptContent,
|
|
1664
|
+
bootstrapScripts: [
|
|
1665
|
+
bootstrapScript
|
|
1666
|
+
],
|
|
1667
|
+
formState
|
|
1668
|
+
});
|
|
1669
|
+
// End the render span only after React completed rendering (including anything inside Suspense boundaries)
|
|
1670
|
+
htmlStream.allReady.finally(()=>{
|
|
1671
|
+
if (renderSpan.isRecording()) renderSpan.end();
|
|
1672
|
+
});
|
|
1673
|
+
const getServerInsertedHTML = (0, _makegetserverinsertedhtml.makeGetServerInsertedHTML)({
|
|
1674
|
+
polyfills,
|
|
1675
|
+
renderServerInsertedHTML,
|
|
1676
|
+
serverCapturedErrors: allCapturedErrors,
|
|
1677
|
+
basePath,
|
|
1678
|
+
tracingMetadata: tracingMetadata
|
|
1732
1679
|
});
|
|
1733
1680
|
/**
|
|
1734
1681
|
* Rules of Static & Dynamic HTML:
|
|
@@ -1739,55 +1686,163 @@ async function renderToStream(requestStore, req, res, ctx, tree, formState, post
|
|
|
1739
1686
|
* 2.) If dynamic HTML support is requested, we must honor that request
|
|
1740
1687
|
* or throw an error. It is the sole responsibility of the caller to
|
|
1741
1688
|
* ensure they aren't e.g. requesting dynamic HTML for a static page.
|
|
1742
|
-
*
|
|
1743
|
-
*
|
|
1744
|
-
*
|
|
1689
|
+
*
|
|
1690
|
+
* 3.) If `shouldWaitOnAllReady` is true, which indicates we need to
|
|
1691
|
+
* resolve all suspenses and generate a full HTML. e.g. when it's a
|
|
1692
|
+
* html limited bot requests, we produce the full HTML content.
|
|
1745
1693
|
*
|
|
1746
1694
|
* These rules help ensure that other existing features like request caching,
|
|
1747
1695
|
* coalescing, and ISR continue working as intended.
|
|
1748
1696
|
*/ const generateStaticHTML = supportsDynamicResponse !== true || !!shouldWaitOnAllReady;
|
|
1749
|
-
return await (0, _nodewebstreamshelper.continueFizzStream)(
|
|
1750
|
-
inlinedDataStream: (0, _useflightresponse.createInlinedDataReadableStream)(
|
|
1751
|
-
// main render rather than the flight data from the error page
|
|
1752
|
-
// render
|
|
1753
|
-
reactServerResult.consume(), nonce, formState),
|
|
1697
|
+
return await (0, _nodewebstreamshelper.continueFizzStream)(htmlStream, {
|
|
1698
|
+
inlinedDataStream: (0, _useflightresponse.createInlinedDataReadableStream)(reactServerResult.consume(), nonce, formState),
|
|
1754
1699
|
isStaticGeneration: generateStaticHTML,
|
|
1755
1700
|
isBuildTimePrerendering: ctx.workStore.isBuildTimePrerendering === true,
|
|
1756
1701
|
buildId: ctx.workStore.buildId,
|
|
1757
|
-
getServerInsertedHTML
|
|
1758
|
-
polyfills,
|
|
1759
|
-
renderServerInsertedHTML,
|
|
1760
|
-
serverCapturedErrors: [],
|
|
1761
|
-
basePath,
|
|
1762
|
-
tracingMetadata: tracingMetadata
|
|
1763
|
-
}),
|
|
1702
|
+
getServerInsertedHTML,
|
|
1764
1703
|
getServerInsertedMetadata,
|
|
1765
1704
|
validateRootLayout: dev
|
|
1766
1705
|
});
|
|
1767
|
-
} catch (
|
|
1768
|
-
if (
|
|
1769
|
-
|
|
1770
|
-
|
|
1706
|
+
} catch (err) {
|
|
1707
|
+
if ((0, _staticgenerationbailout.isStaticGenBailoutError)(err) || typeof err === 'object' && err !== null && 'message' in err && typeof err.message === 'string' && err.message.includes('https://nextjs.org/docs/advanced-features/static-html-export')) {
|
|
1708
|
+
// Ensure that "next dev" prints the red error overlay
|
|
1709
|
+
endSpanWithError(err);
|
|
1710
|
+
throw err;
|
|
1711
|
+
}
|
|
1712
|
+
// If a bailout made it to this point, it means it wasn't wrapped inside
|
|
1713
|
+
// a suspense boundary.
|
|
1714
|
+
const shouldBailoutToCSR = (0, _bailouttocsr.isBailoutToCSRError)(err);
|
|
1715
|
+
if (shouldBailoutToCSR) {
|
|
1716
|
+
const stack = (0, _formatservererror.getStackWithoutErrorMessage)(err);
|
|
1717
|
+
(0, _log.error)(`${err.reason} should be wrapped in a suspense boundary at page "${pagePath}". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout\n${stack}`);
|
|
1718
|
+
endSpanWithError(err);
|
|
1719
|
+
throw err;
|
|
1720
|
+
}
|
|
1721
|
+
let errorType;
|
|
1722
|
+
if ((0, _httpaccessfallback.isHTTPAccessFallbackError)(err)) {
|
|
1723
|
+
res.statusCode = (0, _httpaccessfallback.getAccessFallbackHTTPStatus)(err);
|
|
1724
|
+
metadata.statusCode = res.statusCode;
|
|
1725
|
+
errorType = (0, _httpaccessfallback.getAccessFallbackErrorTypeByStatus)(res.statusCode);
|
|
1726
|
+
} else if ((0, _redirecterror.isRedirectError)(err)) {
|
|
1727
|
+
errorType = 'redirect';
|
|
1728
|
+
res.statusCode = (0, _redirect.getRedirectStatusCodeFromError)(err);
|
|
1729
|
+
metadata.statusCode = res.statusCode;
|
|
1730
|
+
const redirectUrl = (0, _addpathprefix.addPathPrefix)((0, _redirect.getURLFromRedirectError)(err), basePath);
|
|
1731
|
+
// If there were mutable cookies set, we need to set them on the
|
|
1732
|
+
// response.
|
|
1733
|
+
const headers = new Headers();
|
|
1734
|
+
if ((0, _requestcookies.appendMutableCookies)(headers, requestStore.mutableCookies)) {
|
|
1735
|
+
setHeader('set-cookie', Array.from(headers.values()));
|
|
1736
|
+
}
|
|
1737
|
+
setHeader('location', redirectUrl);
|
|
1738
|
+
} else if (!shouldBailoutToCSR) {
|
|
1739
|
+
res.statusCode = 500;
|
|
1740
|
+
metadata.statusCode = res.statusCode;
|
|
1741
|
+
}
|
|
1742
|
+
const [errorPreinitScripts, errorBootstrapScript] = (0, _requiredscripts.getRequiredScripts)(buildManifest, assetPrefix, crossOrigin, subresourceIntegrityManifest, (0, _getassetquerystring.getAssetQueryString)(ctx, false), nonce, '/_not-found/page');
|
|
1743
|
+
let errorRSCPayload;
|
|
1744
|
+
let errorServerStream;
|
|
1745
|
+
try {
|
|
1746
|
+
errorRSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, getErrorRSCPayload, tree, ctx, reactServerErrorsByDigest.has(err.digest) ? null : err, errorType);
|
|
1747
|
+
errorServerStream = _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, serverRenderToReadableStream, errorRSCPayload, clientModules, {
|
|
1748
|
+
filterStackFrame,
|
|
1749
|
+
onError: serverComponentsErrorHandler
|
|
1750
|
+
});
|
|
1751
|
+
if (reactServerResult === null) {
|
|
1752
|
+
// We errored when we did not have an RSC stream to read from. This is not just a render
|
|
1753
|
+
// error, we need to throw early
|
|
1754
|
+
endSpanWithError(err);
|
|
1755
|
+
throw err;
|
|
1756
|
+
}
|
|
1757
|
+
} catch (setupErr) {
|
|
1758
|
+
endSpanWithError(setupErr);
|
|
1759
|
+
throw setupErr;
|
|
1760
|
+
}
|
|
1761
|
+
try {
|
|
1762
|
+
const fizzStream = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, _nodewebstreamshelper.renderToInitialFizzStream, {
|
|
1763
|
+
ReactDOMServer: require('react-dom/server'),
|
|
1764
|
+
element: /*#__PURE__*/ (0, _jsxruntime.jsx)(ErrorApp, {
|
|
1765
|
+
reactServerStream: errorServerStream,
|
|
1766
|
+
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
1767
|
+
preinitScripts: errorPreinitScripts,
|
|
1768
|
+
nonce: nonce,
|
|
1769
|
+
images: ctx.renderOpts.images
|
|
1770
|
+
}),
|
|
1771
|
+
streamOptions: {
|
|
1772
|
+
nonce,
|
|
1773
|
+
bootstrapScriptContent,
|
|
1774
|
+
// Include hydration scripts in the HTML
|
|
1775
|
+
bootstrapScripts: [
|
|
1776
|
+
errorBootstrapScript
|
|
1777
|
+
],
|
|
1778
|
+
formState
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
// End the render span only after React completed rendering (including anything inside Suspense boundaries)
|
|
1782
|
+
fizzStream.allReady.finally(()=>{
|
|
1783
|
+
if (renderSpan.isRecording()) renderSpan.end();
|
|
1784
|
+
});
|
|
1785
|
+
/**
|
|
1786
|
+
* Rules of Static & Dynamic HTML:
|
|
1787
|
+
*
|
|
1788
|
+
* 1.) We must generate static HTML unless the caller explicitly opts
|
|
1789
|
+
* in to dynamic HTML support.
|
|
1790
|
+
*
|
|
1791
|
+
* 2.) If dynamic HTML support is requested, we must honor that request
|
|
1792
|
+
* or throw an error. It is the sole responsibility of the caller to
|
|
1793
|
+
* ensure they aren't e.g. requesting dynamic HTML for a static page.
|
|
1794
|
+
* 3.) If `shouldWaitOnAllReady` is true, which indicates we need to
|
|
1795
|
+
* resolve all suspenses and generate a full HTML. e.g. when it's a
|
|
1796
|
+
* html limited bot requests, we produce the full HTML content.
|
|
1797
|
+
*
|
|
1798
|
+
* These rules help ensure that other existing features like request caching,
|
|
1799
|
+
* coalescing, and ISR continue working as intended.
|
|
1800
|
+
*/ const generateStaticHTML = supportsDynamicResponse !== true || !!shouldWaitOnAllReady;
|
|
1801
|
+
return await (0, _nodewebstreamshelper.continueFizzStream)(fizzStream, {
|
|
1802
|
+
inlinedDataStream: (0, _useflightresponse.createInlinedDataReadableStream)(// This is intentionally using the readable datastream from the
|
|
1803
|
+
// main render rather than the flight data from the error page
|
|
1804
|
+
// render
|
|
1805
|
+
reactServerResult.consume(), nonce, formState),
|
|
1806
|
+
isStaticGeneration: generateStaticHTML,
|
|
1807
|
+
isBuildTimePrerendering: ctx.workStore.isBuildTimePrerendering === true,
|
|
1808
|
+
buildId: ctx.workStore.buildId,
|
|
1809
|
+
getServerInsertedHTML: (0, _makegetserverinsertedhtml.makeGetServerInsertedHTML)({
|
|
1810
|
+
polyfills,
|
|
1811
|
+
renderServerInsertedHTML,
|
|
1812
|
+
serverCapturedErrors: [],
|
|
1813
|
+
basePath,
|
|
1814
|
+
tracingMetadata: tracingMetadata
|
|
1815
|
+
}),
|
|
1816
|
+
getServerInsertedMetadata,
|
|
1817
|
+
validateRootLayout: dev
|
|
1818
|
+
});
|
|
1819
|
+
} catch (finalErr) {
|
|
1820
|
+
if (process.env.NODE_ENV === 'development' && (0, _httpaccessfallback.isHTTPAccessFallbackError)(finalErr)) {
|
|
1821
|
+
const { bailOnRootNotFound } = require('../../client/components/dev-root-http-access-fallback-boundary');
|
|
1822
|
+
bailOnRootNotFound();
|
|
1823
|
+
}
|
|
1824
|
+
endSpanWithError(finalErr);
|
|
1825
|
+
throw finalErr;
|
|
1771
1826
|
}
|
|
1772
|
-
throw finalErr;
|
|
1773
1827
|
}
|
|
1774
|
-
}
|
|
1828
|
+
});
|
|
1775
1829
|
/* eslint-enable @next/internal/no-ambiguous-jsx */ }
|
|
1776
1830
|
async function renderWithRestartOnCacheMissInDev(ctx, initialRequestStore, createRequestStore, getPayload, onError) {
|
|
1777
1831
|
const { htmlRequestId, renderOpts, componentMod: { routeModule: { userland: { loaderTree } } } } = ctx;
|
|
1778
|
-
const {
|
|
1779
|
-
assertClientReferenceManifest(clientReferenceManifest);
|
|
1832
|
+
const { ComponentMod, setCacheStatus, setReactDebugChannel } = renderOpts;
|
|
1780
1833
|
const hasRuntimePrefetch = await (0, _stagedvalidation.anySegmentHasRuntimePrefetchEnabled)(loaderTree);
|
|
1781
1834
|
// If the render is restarted, we'll recreate a fresh request store
|
|
1782
1835
|
let requestStore = initialRequestStore;
|
|
1783
1836
|
const environmentName = ()=>{
|
|
1784
1837
|
const currentStage = requestStore.stagedRendering.currentStage;
|
|
1785
1838
|
switch(currentStage){
|
|
1839
|
+
case _stagedrendering.RenderStage.Before:
|
|
1786
1840
|
case _stagedrendering.RenderStage.Static:
|
|
1787
1841
|
return 'Prerender';
|
|
1788
1842
|
case _stagedrendering.RenderStage.Runtime:
|
|
1789
1843
|
return hasRuntimePrefetch ? 'Prefetch' : 'Prefetchable';
|
|
1790
1844
|
case _stagedrendering.RenderStage.Dynamic:
|
|
1845
|
+
case _stagedrendering.RenderStage.Abandoned:
|
|
1791
1846
|
return 'Server';
|
|
1792
1847
|
default:
|
|
1793
1848
|
currentStage;
|
|
@@ -1814,7 +1869,7 @@ async function renderWithRestartOnCacheMissInDev(ctx, initialRequestStore, creat
|
|
|
1814
1869
|
const initialReactController = new AbortController();
|
|
1815
1870
|
const initialDataController = new AbortController() // Controls hanging promises we create
|
|
1816
1871
|
;
|
|
1817
|
-
const initialStageController = new _stagedrendering.StagedRenderingController(initialDataController.signal);
|
|
1872
|
+
const initialStageController = new _stagedrendering.StagedRenderingController(initialDataController.signal, hasRuntimePrefetch);
|
|
1818
1873
|
requestStore.prerenderResumeDataCache = prerenderResumeDataCache;
|
|
1819
1874
|
// `getRenderResumeDataCache` will fall back to using `prerenderResumeDataCache` as `renderResumeDataCache`,
|
|
1820
1875
|
// so not having a resume data cache won't break any expectations in case we don't need to restart.
|
|
@@ -1823,10 +1878,14 @@ async function renderWithRestartOnCacheMissInDev(ctx, initialRequestStore, creat
|
|
|
1823
1878
|
requestStore.asyncApiPromises = createAsyncApiPromisesInDev(initialStageController, requestStore.cookies, requestStore.mutableCookies, requestStore.headers);
|
|
1824
1879
|
requestStore.cacheSignal = cacheSignal;
|
|
1825
1880
|
let debugChannel = setReactDebugChannel && createDebugChannel();
|
|
1881
|
+
const { clientModules } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
1882
|
+
// Note: The stage controller starts out in the `Before` stage,
|
|
1883
|
+
// where sync IO does not cause aborts, so it's okay if it happens before render.
|
|
1826
1884
|
const initialRscPayload = await getPayload(requestStore);
|
|
1827
|
-
const
|
|
1885
|
+
const maybeInitialStreamResult = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, ()=>(0, _apprenderrenderutils.pipelineInSequentialTasks)(()=>{
|
|
1828
1886
|
// Static stage
|
|
1829
|
-
|
|
1887
|
+
initialStageController.advanceStage(_stagedrendering.RenderStage.Static);
|
|
1888
|
+
const stream = ComponentMod.renderToReadableStream(initialRscPayload, clientModules, {
|
|
1830
1889
|
onError,
|
|
1831
1890
|
environmentName,
|
|
1832
1891
|
filterStackFrame,
|
|
@@ -1839,35 +1898,63 @@ async function renderWithRestartOnCacheMissInDev(ctx, initialRequestStore, creat
|
|
|
1839
1898
|
initialReactController.signal.addEventListener('abort', ()=>{
|
|
1840
1899
|
initialDataController.abort(initialReactController.signal.reason);
|
|
1841
1900
|
});
|
|
1842
|
-
|
|
1843
|
-
|
|
1901
|
+
const [continuationStream, accumulatingStream] = stream.tee();
|
|
1902
|
+
const accumulatedChunksPromise = accumulateStreamChunks(accumulatingStream, initialStageController, initialDataController.signal);
|
|
1903
|
+
return {
|
|
1904
|
+
stream: continuationStream,
|
|
1905
|
+
accumulatedChunksPromise
|
|
1906
|
+
};
|
|
1907
|
+
}, ({ stream, accumulatedChunksPromise })=>{
|
|
1844
1908
|
// Runtime stage
|
|
1845
|
-
initialStageController.
|
|
1846
|
-
|
|
1909
|
+
if (initialStageController.currentStage === _stagedrendering.RenderStage.Abandoned) {
|
|
1910
|
+
// If we abandoned the render in the static stage, we won't proceed further.
|
|
1911
|
+
return null;
|
|
1912
|
+
}
|
|
1913
|
+
// If we had a cache miss in the static stage, we'll have to discard this stream
|
|
1847
1914
|
// and render again once the caches are warm.
|
|
1915
|
+
// If we already advanced stages we similarly had sync IO that might be from module loading
|
|
1916
|
+
// and need to render again once the caches are warm.
|
|
1848
1917
|
if (cacheSignal.hasPendingReads()) {
|
|
1918
|
+
// Regardless of whether we are going to abandon this
|
|
1919
|
+
// render we need the unblock runtime b/c it's essential
|
|
1920
|
+
// filling caches.
|
|
1921
|
+
initialStageController.abandonRender();
|
|
1849
1922
|
return null;
|
|
1850
1923
|
}
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1924
|
+
initialStageController.advanceStage(_stagedrendering.RenderStage.Runtime);
|
|
1925
|
+
return {
|
|
1926
|
+
stream,
|
|
1927
|
+
accumulatedChunksPromise
|
|
1928
|
+
};
|
|
1929
|
+
}, (result)=>{
|
|
1855
1930
|
// Dynamic stage
|
|
1931
|
+
if (result === null || initialStageController.currentStage === _stagedrendering.RenderStage.Abandoned) {
|
|
1932
|
+
// If we abandoned the render in the static or runtime stage, we won't proceed further.
|
|
1933
|
+
return null;
|
|
1934
|
+
}
|
|
1856
1935
|
// If we had cache misses in either of the previous stages,
|
|
1857
1936
|
// then we'll only use this render for filling caches.
|
|
1858
1937
|
// We won't advance the stage, and thus leave dynamic APIs hanging,
|
|
1859
1938
|
// because they won't be cached anyway, so it'd be wasted work.
|
|
1860
|
-
if (
|
|
1939
|
+
if (cacheSignal.hasPendingReads()) {
|
|
1940
|
+
initialStageController.abandonRender();
|
|
1861
1941
|
return null;
|
|
1862
1942
|
}
|
|
1863
|
-
//
|
|
1943
|
+
// Regardless of whether we are going to abandon this
|
|
1944
|
+
// render we need the unblock runtime b/c it's essential
|
|
1945
|
+
// filling caches.
|
|
1864
1946
|
initialStageController.advanceStage(_stagedrendering.RenderStage.Dynamic);
|
|
1865
|
-
return
|
|
1947
|
+
return result;
|
|
1866
1948
|
}));
|
|
1867
|
-
if (
|
|
1868
|
-
// No cache misses. We can use the
|
|
1949
|
+
if (maybeInitialStreamResult !== null) {
|
|
1950
|
+
// No cache misses. We can use the result as-is.
|
|
1869
1951
|
return {
|
|
1870
|
-
stream:
|
|
1952
|
+
stream: maybeInitialStreamResult.stream,
|
|
1953
|
+
accumulatedChunksPromise: maybeInitialStreamResult.accumulatedChunksPromise,
|
|
1954
|
+
staticInterruptReason: initialStageController.getStaticInterruptReason(),
|
|
1955
|
+
runtimeInterruptReason: initialStageController.getRuntimeInterruptReason(),
|
|
1956
|
+
staticStageEndTime: initialStageController.getStaticStageEndTime(),
|
|
1957
|
+
runtimeStageEndTime: initialStageController.getRuntimeStageEndTime(),
|
|
1871
1958
|
debugChannel,
|
|
1872
1959
|
requestStore
|
|
1873
1960
|
};
|
|
@@ -1889,7 +1976,10 @@ async function renderWithRestartOnCacheMissInDev(ctx, initialRequestStore, creat
|
|
|
1889
1976
|
//===============================================
|
|
1890
1977
|
// The initial render acted as a prospective render to warm the caches.
|
|
1891
1978
|
requestStore = createRequestStore();
|
|
1892
|
-
|
|
1979
|
+
// We are going to render this pass all the way through because we've already
|
|
1980
|
+
// filled any caches so we won't be aborting this time.
|
|
1981
|
+
const abortSignal = null;
|
|
1982
|
+
const finalStageController = new _stagedrendering.StagedRenderingController(abortSignal, hasRuntimePrefetch);
|
|
1893
1983
|
// We've filled the caches, so now we can render as usual,
|
|
1894
1984
|
// without any cache-filling mechanics.
|
|
1895
1985
|
requestStore.prerenderResumeDataCache = null;
|
|
@@ -1900,33 +1990,103 @@ async function renderWithRestartOnCacheMissInDev(ctx, initialRequestStore, creat
|
|
|
1900
1990
|
// The initial render already wrote to its debug channel.
|
|
1901
1991
|
// We're not using it, so we need to create a new one.
|
|
1902
1992
|
debugChannel = setReactDebugChannel && createDebugChannel();
|
|
1993
|
+
// Note: The stage controller starts out in the `Before` stage,
|
|
1994
|
+
// where sync IO does not cause aborts, so it's okay if it happens before render.
|
|
1903
1995
|
const finalRscPayload = await getPayload(requestStore);
|
|
1904
|
-
const
|
|
1996
|
+
const finalStreamResult = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, ()=>(0, _apprenderrenderutils.pipelineInSequentialTasks)(()=>{
|
|
1905
1997
|
// Static stage
|
|
1906
|
-
|
|
1998
|
+
finalStageController.advanceStage(_stagedrendering.RenderStage.Static);
|
|
1999
|
+
const stream = ComponentMod.renderToReadableStream(finalRscPayload, clientModules, {
|
|
1907
2000
|
onError,
|
|
1908
2001
|
environmentName,
|
|
1909
2002
|
filterStackFrame,
|
|
1910
2003
|
debugChannel: debugChannel == null ? void 0 : debugChannel.serverSide
|
|
1911
2004
|
});
|
|
1912
|
-
|
|
2005
|
+
const [continuationStream, accumulatingStream] = stream.tee();
|
|
2006
|
+
const accumulatedChunksPromise = accumulateStreamChunks(accumulatingStream, finalStageController, null);
|
|
2007
|
+
return {
|
|
2008
|
+
stream: continuationStream,
|
|
2009
|
+
accumulatedChunksPromise
|
|
2010
|
+
};
|
|
2011
|
+
}, (result)=>{
|
|
1913
2012
|
// Runtime stage
|
|
1914
2013
|
finalStageController.advanceStage(_stagedrendering.RenderStage.Runtime);
|
|
1915
|
-
return
|
|
1916
|
-
}, (
|
|
2014
|
+
return result;
|
|
2015
|
+
}, (result)=>{
|
|
1917
2016
|
// Dynamic stage
|
|
1918
2017
|
finalStageController.advanceStage(_stagedrendering.RenderStage.Dynamic);
|
|
1919
|
-
return
|
|
2018
|
+
return result;
|
|
1920
2019
|
}));
|
|
1921
2020
|
if (process.env.NODE_ENV === 'development' && setCacheStatus) {
|
|
1922
2021
|
setCacheStatus('filled', htmlRequestId);
|
|
1923
2022
|
}
|
|
1924
2023
|
return {
|
|
1925
|
-
stream:
|
|
2024
|
+
stream: finalStreamResult.stream,
|
|
2025
|
+
accumulatedChunksPromise: finalStreamResult.accumulatedChunksPromise,
|
|
2026
|
+
staticInterruptReason: finalStageController.getStaticInterruptReason(),
|
|
2027
|
+
runtimeInterruptReason: finalStageController.getRuntimeInterruptReason(),
|
|
2028
|
+
staticStageEndTime: finalStageController.getStaticStageEndTime(),
|
|
2029
|
+
runtimeStageEndTime: finalStageController.getRuntimeStageEndTime(),
|
|
1926
2030
|
debugChannel,
|
|
1927
2031
|
requestStore
|
|
1928
2032
|
};
|
|
1929
2033
|
}
|
|
2034
|
+
async function accumulateStreamChunks(stream, stageController, signal) {
|
|
2035
|
+
const staticChunks = [];
|
|
2036
|
+
const runtimeChunks = [];
|
|
2037
|
+
const dynamicChunks = [];
|
|
2038
|
+
const reader = stream.getReader();
|
|
2039
|
+
let cancelled = false;
|
|
2040
|
+
function cancel() {
|
|
2041
|
+
if (!cancelled) {
|
|
2042
|
+
cancelled = true;
|
|
2043
|
+
reader.cancel();
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
if (signal) {
|
|
2047
|
+
signal.addEventListener('abort', cancel, {
|
|
2048
|
+
once: true
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
try {
|
|
2052
|
+
while(!cancelled){
|
|
2053
|
+
const { done, value } = await reader.read();
|
|
2054
|
+
if (done) {
|
|
2055
|
+
cancel();
|
|
2056
|
+
break;
|
|
2057
|
+
}
|
|
2058
|
+
switch(stageController.currentStage){
|
|
2059
|
+
case _stagedrendering.RenderStage.Before:
|
|
2060
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('Unexpected stream chunk while in Before stage'), "__NEXT_ERROR_CODE", {
|
|
2061
|
+
value: "E942",
|
|
2062
|
+
enumerable: false,
|
|
2063
|
+
configurable: true
|
|
2064
|
+
});
|
|
2065
|
+
case _stagedrendering.RenderStage.Static:
|
|
2066
|
+
staticChunks.push(value);
|
|
2067
|
+
// fall through
|
|
2068
|
+
case _stagedrendering.RenderStage.Runtime:
|
|
2069
|
+
runtimeChunks.push(value);
|
|
2070
|
+
// fall through
|
|
2071
|
+
case _stagedrendering.RenderStage.Dynamic:
|
|
2072
|
+
dynamicChunks.push(value);
|
|
2073
|
+
break;
|
|
2074
|
+
case _stagedrendering.RenderStage.Abandoned:
|
|
2075
|
+
break;
|
|
2076
|
+
default:
|
|
2077
|
+
stageController.currentStage;
|
|
2078
|
+
break;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
} catch {
|
|
2082
|
+
// When we release the lock we may reject the read
|
|
2083
|
+
}
|
|
2084
|
+
return {
|
|
2085
|
+
staticChunks,
|
|
2086
|
+
runtimeChunks,
|
|
2087
|
+
dynamicChunks
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
1930
2090
|
function createAsyncApiPromisesInDev(stagedRendering, cookies, mutableCookies, headers) {
|
|
1931
2091
|
return {
|
|
1932
2092
|
// Runtime APIs
|
|
@@ -1944,7 +2104,7 @@ function createDebugChannel() {
|
|
|
1944
2104
|
return undefined;
|
|
1945
2105
|
}
|
|
1946
2106
|
let readableController;
|
|
1947
|
-
|
|
2107
|
+
let clientSideReadable = new ReadableStream({
|
|
1948
2108
|
start (controller) {
|
|
1949
2109
|
readableController = controller;
|
|
1950
2110
|
}
|
|
@@ -1968,103 +2128,114 @@ function createDebugChannel() {
|
|
|
1968
2128
|
}
|
|
1969
2129
|
};
|
|
1970
2130
|
}
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
2131
|
+
/**
|
|
2132
|
+
* Logs the given messages, and sends the error instances to the browser as an
|
|
2133
|
+
* RSC stream, where they can be deserialized and logged (or otherwise presented
|
|
2134
|
+
* in the devtools), while leveraging React's capabilities to not only
|
|
2135
|
+
* source-map the stack frames (via findSourceMapURL), but also create virtual
|
|
2136
|
+
* server modules that allow users to inspect the server source code in the
|
|
2137
|
+
* browser.
|
|
2138
|
+
*/ async function logMessagesAndSendErrorsToBrowser(messages, ctx) {
|
|
2139
|
+
const { componentMod: ComponentMod, htmlRequestId, renderOpts } = ctx;
|
|
2140
|
+
const { sendErrorsToBrowser } = renderOpts;
|
|
2141
|
+
const errors = [];
|
|
2142
|
+
for (const message of messages){
|
|
2143
|
+
// Log the error to the CLI. Prevent the logs from being dimmed, which we
|
|
2144
|
+
// apply for other logs during the spawned validation.
|
|
2145
|
+
_consoleasyncstorageexternal.consoleAsyncStorage.exit(()=>{
|
|
2146
|
+
console.error(message);
|
|
2147
|
+
});
|
|
2148
|
+
// Error instances are also sent to the browser. We're currently using a
|
|
2149
|
+
// non-Error message only in debug build mode as a message that is only
|
|
2150
|
+
// meant for the CLI. FIXME: This is a bit spooky action at a distance. We
|
|
2151
|
+
// should maybe have a more explicit way of determining which messages
|
|
2152
|
+
// should be sent to the browser. Regardless, only real errors with a proper
|
|
2153
|
+
// stack make sense to be "replayed" in the browser.
|
|
2154
|
+
if (message instanceof Error) {
|
|
2155
|
+
errors.push(message);
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
if (errors.length > 0) {
|
|
2159
|
+
if (!sendErrorsToBrowser) {
|
|
2160
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('Expected `sendErrorsToBrowser` to be defined in renderOpts.'), "__NEXT_ERROR_CODE", {
|
|
2161
|
+
value: "E947",
|
|
2162
|
+
enumerable: false,
|
|
2163
|
+
configurable: true
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
const { clientModules } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
2167
|
+
const errorsRscStream = ComponentMod.renderToReadableStream(errors, clientModules, {
|
|
2168
|
+
filterStackFrame
|
|
2169
|
+
});
|
|
2170
|
+
sendErrorsToBrowser(errorsRscStream, htmlRequestId);
|
|
2171
|
+
}
|
|
1980
2172
|
}
|
|
1981
2173
|
/**
|
|
1982
2174
|
* This function is a fork of prerenderToStream cacheComponents branch.
|
|
1983
2175
|
* While it doesn't return a stream we want it to have identical
|
|
1984
2176
|
* prerender semantics to prerenderToStream and should update it
|
|
1985
2177
|
* in conjunction with any changes to that function.
|
|
1986
|
-
*/ async function
|
|
1987
|
-
|
|
1988
|
-
const { componentMod: ComponentMod, getDynamicParamFromSegment, implicitTags, nonce, renderOpts, workStore } = ctx;
|
|
2178
|
+
*/ async function spawnStaticShellValidationInDev(accumulatedChunksPromise, staticInterruptReason, runtimeInterruptReason, staticStageEndTime, runtimeStageEndTime, ctx, requestStore, fallbackRouteParams, debugChannelClient) {
|
|
2179
|
+
const { componentMod: ComponentMod, getDynamicParamFromSegment, renderOpts, workStore } = ctx;
|
|
1989
2180
|
const { allowEmptyStaticShell = false } = renderOpts;
|
|
1990
|
-
|
|
1991
|
-
|
|
2181
|
+
const rootParams = (0, _createcomponenttree.getRootParams)(ComponentMod.routeModule.userland.loaderTree, getDynamicParamFromSegment);
|
|
2182
|
+
const hmrRefreshHash = (0, _workunitasyncstorageexternal.getHmrRefreshHash)(workStore, requestStore);
|
|
2183
|
+
// We don't need to continue the prerender process if we already
|
|
2184
|
+
// detected invalid dynamic usage in the initial prerender phase.
|
|
2185
|
+
const { invalidDynamicUsageError } = workStore;
|
|
2186
|
+
if (invalidDynamicUsageError) {
|
|
2187
|
+
return logMessagesAndSendErrorsToBrowser([
|
|
2188
|
+
invalidDynamicUsageError
|
|
2189
|
+
], ctx);
|
|
2190
|
+
}
|
|
2191
|
+
if (staticInterruptReason) {
|
|
2192
|
+
return logMessagesAndSendErrorsToBrowser([
|
|
2193
|
+
staticInterruptReason
|
|
2194
|
+
], ctx);
|
|
2195
|
+
}
|
|
2196
|
+
if (runtimeInterruptReason) {
|
|
2197
|
+
return logMessagesAndSendErrorsToBrowser([
|
|
2198
|
+
runtimeInterruptReason
|
|
2199
|
+
], ctx);
|
|
2200
|
+
}
|
|
2201
|
+
const { staticChunks, runtimeChunks, dynamicChunks } = await accumulatedChunksPromise;
|
|
2202
|
+
// First we warmup SSR with the runtime chunks. This ensures that when we do
|
|
2203
|
+
// the full prerender pass with dynamic tracking module loading won't
|
|
2204
|
+
// interrupt the prerender and can properly observe the entire content
|
|
2205
|
+
await warmupModuleCacheForRuntimeValidationInDev(runtimeChunks, dynamicChunks, rootParams, fallbackRouteParams, allowEmptyStaticShell, ctx);
|
|
2206
|
+
let debugChunks = null;
|
|
2207
|
+
if (debugChannelClient) {
|
|
2208
|
+
debugChunks = [];
|
|
2209
|
+
debugChannelClient.on('data', (c)=>debugChunks.push(c));
|
|
2210
|
+
}
|
|
2211
|
+
const runtimeResult = await validateStagedShell(runtimeChunks, dynamicChunks, debugChunks, runtimeStageEndTime, rootParams, fallbackRouteParams, allowEmptyStaticShell, ctx, hmrRefreshHash, _dynamicrendering.trackDynamicHoleInRuntimeShell);
|
|
2212
|
+
if (runtimeResult.length > 0) {
|
|
2213
|
+
// We have something to report from the runtime validation
|
|
2214
|
+
// We can skip the static validation
|
|
2215
|
+
return logMessagesAndSendErrorsToBrowser(runtimeResult, ctx);
|
|
2216
|
+
}
|
|
2217
|
+
const staticResult = await validateStagedShell(staticChunks, dynamicChunks, debugChunks, staticStageEndTime, rootParams, fallbackRouteParams, allowEmptyStaticShell, ctx, hmrRefreshHash, _dynamicrendering.trackDynamicHoleInStaticShell);
|
|
2218
|
+
return logMessagesAndSendErrorsToBrowser(staticResult, ctx);
|
|
2219
|
+
}
|
|
2220
|
+
async function warmupModuleCacheForRuntimeValidationInDev(runtimeServerChunks, allServerChunks, rootParams, fallbackRouteParams, allowEmptyStaticShell, ctx) {
|
|
2221
|
+
const { implicitTags, nonce, workStore } = ctx;
|
|
2222
|
+
// Warmup SSR
|
|
2223
|
+
const initialClientPrerenderController = new AbortController();
|
|
2224
|
+
const initialClientReactController = new AbortController();
|
|
2225
|
+
const initialClientRenderController = new AbortController();
|
|
1992
2226
|
const preinitScripts = ()=>{};
|
|
1993
2227
|
const { ServerInsertedHTMLProvider } = (0, _serverinsertedhtml.createServerInsertedHTML)();
|
|
1994
|
-
const
|
|
1995
|
-
|
|
1996
|
-
// The prerender controller represents the lifetime of the prerender. It will
|
|
1997
|
-
// be aborted when a task is complete or a synchronously aborting API is
|
|
1998
|
-
// called. Notably, during prospective prerenders, this does not actually
|
|
1999
|
-
// terminate the prerender itself, which will continue until all caches are
|
|
2000
|
-
// filled.
|
|
2001
|
-
const initialServerPrerenderController = new AbortController();
|
|
2002
|
-
// This controller is used to abort the React prerender.
|
|
2003
|
-
const initialServerReactController = new AbortController();
|
|
2004
|
-
// This controller represents the lifetime of the React prerender. Its signal
|
|
2005
|
-
// can be used for any I/O operation to abort the I/O and/or to reject, when
|
|
2006
|
-
// prerendering aborts. This includes our own hanging promises for accessing
|
|
2007
|
-
// request data, and for fetch calls. It might be replaced in the future by
|
|
2008
|
-
// React.cacheSignal(). It's aborted after the React controller, so that no
|
|
2009
|
-
// pending I/O can register abort listeners that are called before React's
|
|
2010
|
-
// abort listener is called. This ensures that pending I/O is not rejected too
|
|
2011
|
-
// early when aborting the prerender. Notably, during the prospective
|
|
2012
|
-
// prerender, it is different from the prerender controller because we don't
|
|
2013
|
-
// want to end the React prerender until all caches are filled.
|
|
2014
|
-
const initialServerRenderController = new AbortController();
|
|
2015
|
-
// The cacheSignal helps us track whether caches are still filling or we are
|
|
2016
|
-
// ready to cut the render off.
|
|
2017
|
-
const cacheSignal = new _cachesignal.CacheSignal();
|
|
2018
|
-
const { createElement } = ComponentMod;
|
|
2019
|
-
// The resume data cache here should use a fresh instance as it's
|
|
2020
|
-
// performing a fresh prerender. If we get to implementing the
|
|
2021
|
-
// prerendering of an already prerendered page, we should use the passed
|
|
2022
|
-
// resume data cache instead.
|
|
2023
|
-
const prerenderResumeDataCache = (0, _resumedatacache.createPrerenderResumeDataCache)();
|
|
2024
|
-
const initialServerPayloadPrerenderStore = {
|
|
2025
|
-
type: 'prerender',
|
|
2026
|
-
phase: 'render',
|
|
2027
|
-
rootParams,
|
|
2028
|
-
fallbackRouteParams,
|
|
2029
|
-
implicitTags,
|
|
2030
|
-
// While this render signal isn't going to be used to abort a React render while getting the RSC payload
|
|
2031
|
-
// various request data APIs bind to this controller to reject after completion.
|
|
2032
|
-
renderSignal: initialServerRenderController.signal,
|
|
2033
|
-
// When we generate the RSC payload we might abort this controller due to sync IO
|
|
2034
|
-
// but we don't actually care about sync IO in this phase so we use a throw away controller
|
|
2035
|
-
// that isn't connected to anything
|
|
2036
|
-
controller: new AbortController(),
|
|
2037
|
-
// During the initial prerender we need to track all cache reads to ensure
|
|
2038
|
-
// we render long enough to fill every cache it is possible to visit during
|
|
2039
|
-
// the final prerender.
|
|
2040
|
-
cacheSignal,
|
|
2041
|
-
dynamicTracking: null,
|
|
2042
|
-
allowEmptyStaticShell,
|
|
2043
|
-
revalidate: _constants1.INFINITE_CACHE,
|
|
2044
|
-
expire: _constants1.INFINITE_CACHE,
|
|
2045
|
-
stale: _constants1.INFINITE_CACHE,
|
|
2046
|
-
tags: [
|
|
2047
|
-
...implicitTags.tags
|
|
2048
|
-
],
|
|
2049
|
-
prerenderResumeDataCache,
|
|
2050
|
-
renderResumeDataCache: null,
|
|
2051
|
-
hmrRefreshHash
|
|
2052
|
-
};
|
|
2053
|
-
// We're not going to use the result of this render because the only time it could be used
|
|
2054
|
-
// is if it completes in a microtask and that's likely very rare for any non-trivial app
|
|
2055
|
-
const initialServerPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(initialServerPayloadPrerenderStore, getRSCPayload, tree, ctx, isNotFound);
|
|
2056
|
-
const initialServerPrerenderStore = {
|
|
2057
|
-
type: 'prerender',
|
|
2228
|
+
const initialClientPrerenderStore = {
|
|
2229
|
+
type: 'prerender-client',
|
|
2058
2230
|
phase: 'render',
|
|
2059
2231
|
rootParams,
|
|
2060
2232
|
fallbackRouteParams,
|
|
2061
2233
|
implicitTags,
|
|
2062
|
-
renderSignal:
|
|
2063
|
-
controller:
|
|
2064
|
-
//
|
|
2065
|
-
//
|
|
2066
|
-
|
|
2067
|
-
cacheSignal,
|
|
2234
|
+
renderSignal: initialClientRenderController.signal,
|
|
2235
|
+
controller: initialClientPrerenderController,
|
|
2236
|
+
// For HTML Generation the only cache tracked activity
|
|
2237
|
+
// is module loading, which has it's own cache signal
|
|
2238
|
+
cacheSignal: null,
|
|
2068
2239
|
dynamicTracking: null,
|
|
2069
2240
|
allowEmptyStaticShell,
|
|
2070
2241
|
revalidate: _constants1.INFINITE_CACHE,
|
|
@@ -2073,12 +2244,24 @@ function createValidationOutlet() {
|
|
|
2073
2244
|
tags: [
|
|
2074
2245
|
...implicitTags.tags
|
|
2075
2246
|
],
|
|
2076
|
-
|
|
2247
|
+
// TODO should this be removed from client stores?
|
|
2248
|
+
prerenderResumeDataCache: null,
|
|
2077
2249
|
renderResumeDataCache: null,
|
|
2078
|
-
hmrRefreshHash
|
|
2250
|
+
hmrRefreshHash: undefined
|
|
2079
2251
|
};
|
|
2080
|
-
const
|
|
2081
|
-
|
|
2252
|
+
const runtimeServerStream = createNodeStreamFromChunks(runtimeServerChunks, allServerChunks, initialClientReactController.signal);
|
|
2253
|
+
const prerender = require('react-dom/static').prerender;
|
|
2254
|
+
const pendingInitialClientResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(initialClientPrerenderStore, prerender, // eslint-disable-next-line @next/internal/no-ambiguous-jsx -- React Client
|
|
2255
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
2256
|
+
reactServerStream: runtimeServerStream,
|
|
2257
|
+
reactDebugStream: undefined,
|
|
2258
|
+
debugEndTime: undefined,
|
|
2259
|
+
preinitScripts: preinitScripts,
|
|
2260
|
+
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
2261
|
+
nonce: nonce,
|
|
2262
|
+
images: ctx.renderOpts.images
|
|
2263
|
+
}), {
|
|
2264
|
+
signal: initialClientReactController.signal,
|
|
2082
2265
|
onError: (err)=>{
|
|
2083
2266
|
const digest = (0, _createerrorhandler.getDigestForWellKnownError)(err);
|
|
2084
2267
|
if (digest) {
|
|
@@ -2089,232 +2272,55 @@ function createValidationOutlet() {
|
|
|
2089
2272
|
console.error(err);
|
|
2090
2273
|
return undefined;
|
|
2091
2274
|
}
|
|
2092
|
-
if (
|
|
2093
|
-
|
|
2094
|
-
// the error is caused by unfinished components within the render
|
|
2095
|
-
return;
|
|
2275
|
+
if (initialClientReactController.signal.aborted) {
|
|
2276
|
+
// These are expected errors that might error the prerender. we ignore them.
|
|
2096
2277
|
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2097
|
-
|
|
2278
|
+
// We don't normally log these errors because we are going to retry anyway but
|
|
2279
|
+
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
2280
|
+
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
|
|
2098
2281
|
}
|
|
2099
|
-
}
|
|
2100
|
-
// We don't want to stop rendering until the cacheSignal is complete so we pass
|
|
2101
|
-
// a different signal to this render call than is used by dynamic APIs to signify
|
|
2102
|
-
// transitioning out of the prerender environment
|
|
2103
|
-
signal: initialServerReactController.signal
|
|
2282
|
+
}
|
|
2104
2283
|
});
|
|
2105
2284
|
// The listener to abort our own render controller must be added after React
|
|
2106
|
-
// has added its listener, to ensure that pending I/O is not
|
|
2107
|
-
// too early.
|
|
2108
|
-
|
|
2109
|
-
|
|
2285
|
+
// has added its listener, to ensure that pending I/O is not
|
|
2286
|
+
// aborted/rejected too early.
|
|
2287
|
+
initialClientReactController.signal.addEventListener('abort', ()=>{
|
|
2288
|
+
initialClientRenderController.abort();
|
|
2110
2289
|
}, {
|
|
2111
2290
|
once: true
|
|
2112
2291
|
});
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
await cacheSignal.cacheReady();
|
|
2116
|
-
initialServerReactController.abort();
|
|
2117
|
-
// We don't need to continue the prerender process if we already
|
|
2118
|
-
// detected invalid dynamic usage in the initial prerender phase.
|
|
2119
|
-
const { invalidDynamicUsageError } = workStore;
|
|
2120
|
-
if (invalidDynamicUsageError) {
|
|
2121
|
-
resolveValidation(createElement(LogSafely, {
|
|
2122
|
-
fn: ()=>{
|
|
2123
|
-
console.error(invalidDynamicUsageError);
|
|
2124
|
-
}
|
|
2125
|
-
}));
|
|
2126
|
-
return;
|
|
2127
|
-
}
|
|
2128
|
-
let initialServerResult;
|
|
2129
|
-
try {
|
|
2130
|
-
initialServerResult = await (0, _apprenderprerenderutils.createReactServerPrerenderResult)(pendingInitialServerResult);
|
|
2131
|
-
} catch (err) {
|
|
2132
|
-
if (initialServerReactController.signal.aborted || initialServerPrerenderController.signal.aborted) {
|
|
2292
|
+
pendingInitialClientResult.catch((err)=>{
|
|
2293
|
+
if (initialClientReactController.signal.aborted || (0, _dynamicrendering.isPrerenderInterruptedError)(err)) {
|
|
2133
2294
|
// These are expected errors that might error the prerender. we ignore them.
|
|
2134
2295
|
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2135
2296
|
// We don't normally log these errors because we are going to retry anyway but
|
|
2136
2297
|
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
2137
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
2298
|
+
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
|
|
2138
2299
|
}
|
|
2139
|
-
}
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
implicitTags,
|
|
2150
|
-
renderSignal: initialClientRenderController.signal,
|
|
2151
|
-
controller: initialClientPrerenderController,
|
|
2152
|
-
// For HTML Generation the only cache tracked activity
|
|
2153
|
-
// is module loading, which has it's own cache signal
|
|
2154
|
-
cacheSignal: null,
|
|
2155
|
-
dynamicTracking: null,
|
|
2156
|
-
allowEmptyStaticShell,
|
|
2157
|
-
revalidate: _constants1.INFINITE_CACHE,
|
|
2158
|
-
expire: _constants1.INFINITE_CACHE,
|
|
2159
|
-
stale: _constants1.INFINITE_CACHE,
|
|
2160
|
-
tags: [
|
|
2161
|
-
...implicitTags.tags
|
|
2162
|
-
],
|
|
2163
|
-
prerenderResumeDataCache,
|
|
2164
|
-
renderResumeDataCache: null,
|
|
2165
|
-
hmrRefreshHash: undefined
|
|
2166
|
-
};
|
|
2167
|
-
const prerender = require('react-dom/static').prerender;
|
|
2168
|
-
const pendingInitialClientResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(initialClientPrerenderStore, prerender, // eslint-disable-next-line @next/internal/no-ambiguous-jsx -- React Client
|
|
2169
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
2170
|
-
reactServerStream: initialServerResult.asUnclosingStream(),
|
|
2171
|
-
reactDebugStream: undefined,
|
|
2172
|
-
preinitScripts: preinitScripts,
|
|
2173
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
2174
|
-
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
2175
|
-
nonce: nonce,
|
|
2176
|
-
images: ctx.renderOpts.images
|
|
2177
|
-
}), {
|
|
2178
|
-
signal: initialClientReactController.signal,
|
|
2179
|
-
onError: (err)=>{
|
|
2180
|
-
const digest = (0, _createerrorhandler.getDigestForWellKnownError)(err);
|
|
2181
|
-
if (digest) {
|
|
2182
|
-
return digest;
|
|
2183
|
-
}
|
|
2184
|
-
if ((0, _reactlargeshellerror.isReactLargeShellError)(err)) {
|
|
2185
|
-
// TODO: Aggregate
|
|
2186
|
-
console.error(err);
|
|
2187
|
-
return undefined;
|
|
2188
|
-
}
|
|
2189
|
-
if (initialClientReactController.signal.aborted) {
|
|
2190
|
-
// These are expected errors that might error the prerender. we ignore them.
|
|
2191
|
-
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2192
|
-
// We don't normally log these errors because we are going to retry anyway but
|
|
2193
|
-
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
2194
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
2197
|
-
});
|
|
2198
|
-
// The listener to abort our own render controller must be added after React
|
|
2199
|
-
// has added its listener, to ensure that pending I/O is not
|
|
2200
|
-
// aborted/rejected too early.
|
|
2201
|
-
initialClientReactController.signal.addEventListener('abort', ()=>{
|
|
2202
|
-
initialClientRenderController.abort();
|
|
2203
|
-
}, {
|
|
2204
|
-
once: true
|
|
2205
|
-
});
|
|
2206
|
-
pendingInitialClientResult.catch((err)=>{
|
|
2207
|
-
if (initialClientReactController.signal.aborted || (0, _dynamicrendering.isPrerenderInterruptedError)(err)) {
|
|
2208
|
-
// These are expected errors that might error the prerender. we ignore them.
|
|
2209
|
-
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2210
|
-
// We don't normally log these errors because we are going to retry anyway but
|
|
2211
|
-
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
2212
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
2213
|
-
}
|
|
2214
|
-
});
|
|
2215
|
-
// This is mostly needed for dynamic `import()`s in client components.
|
|
2216
|
-
// Promises passed to client were already awaited above (assuming that they came from cached functions)
|
|
2217
|
-
(0, _trackmoduleloadingexternal.trackPendingModules)(cacheSignal);
|
|
2218
|
-
await cacheSignal.cacheReady();
|
|
2219
|
-
initialClientReactController.abort();
|
|
2220
|
-
}
|
|
2221
|
-
const finalServerReactController = new AbortController();
|
|
2222
|
-
const finalServerRenderController = new AbortController();
|
|
2223
|
-
const finalServerPayloadPrerenderStore = {
|
|
2224
|
-
type: 'prerender',
|
|
2225
|
-
phase: 'render',
|
|
2226
|
-
rootParams,
|
|
2227
|
-
fallbackRouteParams,
|
|
2228
|
-
implicitTags,
|
|
2229
|
-
// While this render signal isn't going to be used to abort a React render while getting the RSC payload
|
|
2230
|
-
// various request data APIs bind to this controller to reject after completion.
|
|
2231
|
-
renderSignal: finalServerRenderController.signal,
|
|
2232
|
-
// When we generate the RSC payload we might abort this controller due to sync IO
|
|
2233
|
-
// but we don't actually care about sync IO in this phase so we use a throw away controller
|
|
2234
|
-
// that isn't connected to anything
|
|
2235
|
-
controller: new AbortController(),
|
|
2236
|
-
// All caches we could read must already be filled so no tracking is necessary
|
|
2237
|
-
cacheSignal: null,
|
|
2238
|
-
dynamicTracking: null,
|
|
2239
|
-
allowEmptyStaticShell,
|
|
2240
|
-
revalidate: _constants1.INFINITE_CACHE,
|
|
2241
|
-
expire: _constants1.INFINITE_CACHE,
|
|
2242
|
-
stale: _constants1.INFINITE_CACHE,
|
|
2243
|
-
tags: [
|
|
2244
|
-
...implicitTags.tags
|
|
2245
|
-
],
|
|
2246
|
-
prerenderResumeDataCache,
|
|
2247
|
-
renderResumeDataCache: null,
|
|
2248
|
-
hmrRefreshHash
|
|
2249
|
-
};
|
|
2250
|
-
const finalAttemptRSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(finalServerPayloadPrerenderStore, getRSCPayload, tree, ctx, isNotFound);
|
|
2251
|
-
const serverDynamicTracking = (0, _dynamicrendering.createDynamicTrackingState)(false // isDebugDynamicAccesses
|
|
2252
|
-
);
|
|
2253
|
-
const finalServerPrerenderStore = {
|
|
2254
|
-
type: 'prerender',
|
|
2255
|
-
phase: 'render',
|
|
2256
|
-
rootParams,
|
|
2257
|
-
fallbackRouteParams,
|
|
2258
|
-
implicitTags,
|
|
2259
|
-
renderSignal: finalServerRenderController.signal,
|
|
2260
|
-
controller: finalServerReactController,
|
|
2261
|
-
// All caches we could read must already be filled so no tracking is necessary
|
|
2262
|
-
cacheSignal: null,
|
|
2263
|
-
dynamicTracking: serverDynamicTracking,
|
|
2264
|
-
allowEmptyStaticShell,
|
|
2265
|
-
revalidate: _constants1.INFINITE_CACHE,
|
|
2266
|
-
expire: _constants1.INFINITE_CACHE,
|
|
2267
|
-
stale: _constants1.INFINITE_CACHE,
|
|
2268
|
-
tags: [
|
|
2269
|
-
...implicitTags.tags
|
|
2270
|
-
],
|
|
2271
|
-
prerenderResumeDataCache,
|
|
2272
|
-
renderResumeDataCache: null,
|
|
2273
|
-
hmrRefreshHash
|
|
2274
|
-
};
|
|
2275
|
-
const reactServerResult = await (0, _apprenderprerenderutils.createReactServerPrerenderResult)((0, _apprenderprerenderutils.prerenderAndAbortInSequentialTasks)(async ()=>{
|
|
2276
|
-
const pendingPrerenderResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(// The store to scope
|
|
2277
|
-
finalServerPrerenderStore, // The function to run
|
|
2278
|
-
ComponentMod.prerender, // ... the arguments for the function to run
|
|
2279
|
-
finalAttemptRSCPayload, clientReferenceManifest.clientModules, {
|
|
2280
|
-
filterStackFrame,
|
|
2281
|
-
onError: (err)=>{
|
|
2282
|
-
if (finalServerReactController.signal.aborted && (0, _dynamicrendering.isPrerenderInterruptedError)(err)) {
|
|
2283
|
-
return err.digest;
|
|
2284
|
-
}
|
|
2285
|
-
if ((0, _reactlargeshellerror.isReactLargeShellError)(err)) {
|
|
2286
|
-
// TODO: Aggregate
|
|
2287
|
-
console.error(err);
|
|
2288
|
-
return undefined;
|
|
2289
|
-
}
|
|
2290
|
-
return (0, _createerrorhandler.getDigestForWellKnownError)(err);
|
|
2291
|
-
},
|
|
2292
|
-
signal: finalServerReactController.signal
|
|
2293
|
-
});
|
|
2294
|
-
// The listener to abort our own render controller must be added after
|
|
2295
|
-
// React has added its listener, to ensure that pending I/O is not
|
|
2296
|
-
// aborted/rejected too early.
|
|
2297
|
-
finalServerReactController.signal.addEventListener('abort', ()=>{
|
|
2298
|
-
finalServerRenderController.abort();
|
|
2299
|
-
}, {
|
|
2300
|
-
once: true
|
|
2301
|
-
});
|
|
2302
|
-
return pendingPrerenderResult;
|
|
2303
|
-
}, ()=>{
|
|
2304
|
-
finalServerReactController.abort();
|
|
2305
|
-
}));
|
|
2300
|
+
});
|
|
2301
|
+
// This is mostly needed for dynamic `import()`s in client components.
|
|
2302
|
+
// Promises passed to client were already awaited above (assuming that they came from cached functions)
|
|
2303
|
+
const cacheSignal = new _cachesignal.CacheSignal();
|
|
2304
|
+
(0, _trackmoduleloadingexternal.trackPendingModules)(cacheSignal);
|
|
2305
|
+
await cacheSignal.cacheReady();
|
|
2306
|
+
initialClientReactController.abort();
|
|
2307
|
+
}
|
|
2308
|
+
async function validateStagedShell(stageChunks, allServerChunks, debugChunks, debugEndTime, rootParams, fallbackRouteParams, allowEmptyStaticShell, ctx, hmrRefreshHash, trackDynamicHole) {
|
|
2309
|
+
const { implicitTags, nonce, workStore } = ctx;
|
|
2306
2310
|
const clientDynamicTracking = (0, _dynamicrendering.createDynamicTrackingState)(false //isDebugDynamicAccesses
|
|
2307
2311
|
);
|
|
2308
|
-
const
|
|
2309
|
-
const
|
|
2312
|
+
const clientReactController = new AbortController();
|
|
2313
|
+
const clientRenderController = new AbortController();
|
|
2314
|
+
const preinitScripts = ()=>{};
|
|
2315
|
+
const { ServerInsertedHTMLProvider } = (0, _serverinsertedhtml.createServerInsertedHTML)();
|
|
2310
2316
|
const finalClientPrerenderStore = {
|
|
2311
2317
|
type: 'prerender-client',
|
|
2312
2318
|
phase: 'render',
|
|
2313
2319
|
rootParams,
|
|
2314
2320
|
fallbackRouteParams,
|
|
2315
2321
|
implicitTags,
|
|
2316
|
-
renderSignal:
|
|
2317
|
-
controller:
|
|
2322
|
+
renderSignal: clientRenderController.signal,
|
|
2323
|
+
controller: clientReactController,
|
|
2318
2324
|
// No APIs require a cacheSignal through the workUnitStore during the HTML prerender
|
|
2319
2325
|
cacheSignal: null,
|
|
2320
2326
|
dynamicTracking: clientDynamicTracking,
|
|
@@ -2325,30 +2331,33 @@ function createValidationOutlet() {
|
|
|
2325
2331
|
tags: [
|
|
2326
2332
|
...implicitTags.tags
|
|
2327
2333
|
],
|
|
2328
|
-
|
|
2334
|
+
// TODO should this be removed from client stores?
|
|
2335
|
+
prerenderResumeDataCache: null,
|
|
2329
2336
|
renderResumeDataCache: null,
|
|
2330
2337
|
hmrRefreshHash
|
|
2331
2338
|
};
|
|
2332
|
-
let
|
|
2339
|
+
let runtimeDynamicValidation = (0, _dynamicrendering.createDynamicValidationState)();
|
|
2340
|
+
const serverStream = createNodeStreamFromChunks(stageChunks, allServerChunks, clientReactController.signal);
|
|
2341
|
+
const debugChannelClient = debugChunks ? createNodeStreamFromChunks(debugChunks, debugChunks, clientReactController.signal) : undefined;
|
|
2342
|
+
const prerender = require('react-dom/static').prerender;
|
|
2333
2343
|
try {
|
|
2334
|
-
const prerender = require('react-dom/static').prerender;
|
|
2335
2344
|
let { prelude: unprocessedPrelude } = await (0, _apprenderprerenderutils.prerenderAndAbortInSequentialTasks)(()=>{
|
|
2336
2345
|
const pendingFinalClientResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(finalClientPrerenderStore, prerender, // eslint-disable-next-line @next/internal/no-ambiguous-jsx -- React Client
|
|
2337
2346
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
2338
|
-
reactServerStream:
|
|
2339
|
-
reactDebugStream:
|
|
2347
|
+
reactServerStream: serverStream,
|
|
2348
|
+
reactDebugStream: debugChannelClient,
|
|
2349
|
+
debugEndTime: debugEndTime,
|
|
2340
2350
|
preinitScripts: preinitScripts,
|
|
2341
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
2342
2351
|
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
2343
2352
|
nonce: nonce,
|
|
2344
2353
|
images: ctx.renderOpts.images
|
|
2345
2354
|
}), {
|
|
2346
|
-
signal:
|
|
2355
|
+
signal: clientReactController.signal,
|
|
2347
2356
|
onError: (err, errorInfo)=>{
|
|
2348
|
-
if ((0, _dynamicrendering.isPrerenderInterruptedError)(err) ||
|
|
2357
|
+
if ((0, _dynamicrendering.isPrerenderInterruptedError)(err) || clientReactController.signal.aborted) {
|
|
2349
2358
|
const componentStack = errorInfo.componentStack;
|
|
2350
2359
|
if (typeof componentStack === 'string') {
|
|
2351
|
-
(
|
|
2360
|
+
trackDynamicHole(workStore, componentStack, runtimeDynamicValidation, clientDynamicTracking);
|
|
2352
2361
|
}
|
|
2353
2362
|
return;
|
|
2354
2363
|
}
|
|
@@ -2363,44 +2372,27 @@ function createValidationOutlet() {
|
|
|
2363
2372
|
// The listener to abort our own render controller must be added after
|
|
2364
2373
|
// React has added its listener, to ensure that pending I/O is not
|
|
2365
2374
|
// aborted/rejected too early.
|
|
2366
|
-
|
|
2367
|
-
|
|
2375
|
+
clientReactController.signal.addEventListener('abort', ()=>{
|
|
2376
|
+
clientRenderController.abort();
|
|
2368
2377
|
}, {
|
|
2369
2378
|
once: true
|
|
2370
2379
|
});
|
|
2371
2380
|
return pendingFinalClientResult;
|
|
2372
2381
|
}, ()=>{
|
|
2373
|
-
|
|
2382
|
+
clientReactController.abort();
|
|
2374
2383
|
});
|
|
2375
2384
|
const { preludeIsEmpty } = await (0, _apprenderprerenderutils.processPrelude)(unprocessedPrelude);
|
|
2376
|
-
|
|
2377
|
-
fn: _dynamicrendering.throwIfDisallowedDynamic.bind(null, workStore, preludeIsEmpty ? _dynamicrendering.PreludeState.Empty : _dynamicrendering.PreludeState.Full, dynamicValidation, serverDynamicTracking)
|
|
2378
|
-
}));
|
|
2385
|
+
return (0, _dynamicrendering.getStaticShellDisallowedDynamicReasons)(workStore, preludeIsEmpty ? _dynamicrendering.PreludeState.Empty : _dynamicrendering.PreludeState.Full, runtimeDynamicValidation);
|
|
2379
2386
|
} catch (thrownValue) {
|
|
2380
2387
|
// Even if the root errors we still want to report any cache components errors
|
|
2381
2388
|
// that were discovered before the root errored.
|
|
2382
|
-
let
|
|
2389
|
+
let errors = (0, _dynamicrendering.getStaticShellDisallowedDynamicReasons)(workStore, _dynamicrendering.PreludeState.Errored, runtimeDynamicValidation);
|
|
2383
2390
|
if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2384
|
-
|
|
2385
|
-
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
2386
|
-
const originalLoggingFunction = loggingFunction;
|
|
2387
|
-
loggingFunction = ()=>{
|
|
2388
|
-
console.error('During dynamic validation the root of the page errored. The next logged error is the thrown value. It may be a duplicate of errors reported during the normal development mode render.');
|
|
2389
|
-
console.error(thrownValue);
|
|
2390
|
-
originalLoggingFunction();
|
|
2391
|
-
};
|
|
2391
|
+
errors.unshift('During dynamic validation the root of the page errored. The next logged error is the thrown value. It may be a duplicate of errors reported during the normal development mode render.', thrownValue);
|
|
2392
2392
|
}
|
|
2393
|
-
|
|
2394
|
-
fn: loggingFunction
|
|
2395
|
-
}));
|
|
2393
|
+
return errors;
|
|
2396
2394
|
}
|
|
2397
2395
|
}
|
|
2398
|
-
async function LogSafely({ fn }) {
|
|
2399
|
-
try {
|
|
2400
|
-
await fn();
|
|
2401
|
-
} catch {}
|
|
2402
|
-
return null;
|
|
2403
|
-
}
|
|
2404
2396
|
/**
|
|
2405
2397
|
* Determines whether we should generate static flight data.
|
|
2406
2398
|
*/ function shouldGenerateStaticFlightData(workStore) {
|
|
@@ -2414,8 +2406,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2414
2406
|
// more explicit than making it an optional function argument
|
|
2415
2407
|
const formState = null;
|
|
2416
2408
|
const { assetPrefix, getDynamicParamFromSegment, implicitTags, nonce, pagePath, renderOpts, workStore } = ctx;
|
|
2417
|
-
const { allowEmptyStaticShell = false, basePath, buildManifest,
|
|
2418
|
-
assertClientReferenceManifest(clientReferenceManifest);
|
|
2409
|
+
const { allowEmptyStaticShell = false, basePath, buildManifest, ComponentMod, crossOrigin, dev = false, experimental, isDebugDynamicAccesses, nextExport = false, onInstrumentationRequestError, page, reactMaxHeadersLength, subresourceIntegrityManifest, cacheComponents } = renderOpts;
|
|
2419
2410
|
const rootParams = (0, _createcomponenttree.getRootParams)(tree, getDynamicParamFromSegment);
|
|
2420
2411
|
const { ServerInsertedHTMLProvider, renderServerInsertedHTML } = (0, _serverinsertedhtml.createServerInsertedHTML)();
|
|
2421
2412
|
const getServerInsertedMetadata = (0, _createserverinsertedmetadata.createServerInsertedMetadata)(nonce);
|
|
@@ -2430,18 +2421,25 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2430
2421
|
const [preinitScripts, bootstrapScript] = (0, _requiredscripts.getRequiredScripts)(buildManifest, // Why is assetPrefix optional on renderOpts?
|
|
2431
2422
|
// @TODO make it default empty string on renderOpts and get rid of it from ctx
|
|
2432
2423
|
assetPrefix, crossOrigin, subresourceIntegrityManifest, (0, _getassetquerystring.getAssetQueryString)(ctx, true), nonce, page);
|
|
2433
|
-
const reactServerErrorsByDigest =
|
|
2424
|
+
const { reactServerErrorsByDigest } = workStore;
|
|
2434
2425
|
// We don't report errors during prerendering through our instrumentation hooks
|
|
2435
|
-
const
|
|
2436
|
-
function onHTMLRenderRSCError(err) {
|
|
2437
|
-
|
|
2426
|
+
const reportErrors = !experimental.isRoutePPREnabled;
|
|
2427
|
+
function onHTMLRenderRSCError(err, silenceLog) {
|
|
2428
|
+
if (reportErrors) {
|
|
2429
|
+
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, createErrorContext(ctx, 'react-server-components'), silenceLog);
|
|
2430
|
+
}
|
|
2438
2431
|
}
|
|
2439
|
-
const serverComponentsErrorHandler = (0, _createerrorhandler.
|
|
2432
|
+
const serverComponentsErrorHandler = (0, _createerrorhandler.createReactServerErrorHandler)(dev, nextExport, reactServerErrorsByDigest, onHTMLRenderRSCError);
|
|
2440
2433
|
function onHTMLRenderSSRError(err) {
|
|
2441
|
-
|
|
2434
|
+
if (reportErrors) {
|
|
2435
|
+
// We don't need to silence logs here. onHTMLRenderSSRError won't be
|
|
2436
|
+
// called at all if the error was logged before in the RSC error handler.
|
|
2437
|
+
const silenceLog = false;
|
|
2438
|
+
return onInstrumentationRequestError == null ? void 0 : onInstrumentationRequestError(err, req, createErrorContext(ctx, 'server-rendering'), silenceLog);
|
|
2439
|
+
}
|
|
2442
2440
|
}
|
|
2443
2441
|
const allCapturedErrors = [];
|
|
2444
|
-
const htmlRendererErrorHandler = (0, _createerrorhandler.createHTMLErrorHandler)(dev, nextExport, reactServerErrorsByDigest, allCapturedErrors,
|
|
2442
|
+
const htmlRendererErrorHandler = (0, _createerrorhandler.createHTMLErrorHandler)(dev, nextExport, reactServerErrorsByDigest, allCapturedErrors, onHTMLRenderSSRError);
|
|
2445
2443
|
let reactServerPrerenderResult = null;
|
|
2446
2444
|
const setMetadataHeader = (name)=>{
|
|
2447
2445
|
metadata.headers ??= {};
|
|
@@ -2463,6 +2461,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2463
2461
|
setMetadataHeader(name);
|
|
2464
2462
|
};
|
|
2465
2463
|
const selectStaleTime = createSelectStaleTime(experimental);
|
|
2464
|
+
const { clientModules } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
2466
2465
|
let prerenderStore = null;
|
|
2467
2466
|
try {
|
|
2468
2467
|
if (cacheComponents) {
|
|
@@ -2570,7 +2569,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2570
2569
|
renderResumeDataCache,
|
|
2571
2570
|
hmrRefreshHash: undefined
|
|
2572
2571
|
};
|
|
2573
|
-
const pendingInitialServerResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(initialServerPrerenderStore, ComponentMod.prerender, initialServerPayload,
|
|
2572
|
+
const pendingInitialServerResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(initialServerPrerenderStore, ComponentMod.prerender, initialServerPayload, clientModules, {
|
|
2574
2573
|
filterStackFrame,
|
|
2575
2574
|
onError: (err)=>{
|
|
2576
2575
|
const digest = (0, _createerrorhandler.getDigestForWellKnownError)(err);
|
|
@@ -2587,7 +2586,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2587
2586
|
// the error is caused by unfinished components within the render
|
|
2588
2587
|
return;
|
|
2589
2588
|
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2590
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
2589
|
+
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
|
|
2591
2590
|
}
|
|
2592
2591
|
},
|
|
2593
2592
|
// We don't want to stop rendering until the cacheSignal is complete so we pass
|
|
@@ -2623,7 +2622,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2623
2622
|
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2624
2623
|
// We don't normally log these errors because we are going to retry anyway but
|
|
2625
2624
|
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
2626
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
2625
|
+
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
|
|
2627
2626
|
}
|
|
2628
2627
|
}
|
|
2629
2628
|
if (initialServerResult) {
|
|
@@ -2658,8 +2657,8 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2658
2657
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
2659
2658
|
reactServerStream: initialServerResult.asUnclosingStream(),
|
|
2660
2659
|
reactDebugStream: undefined,
|
|
2660
|
+
debugEndTime: undefined,
|
|
2661
2661
|
preinitScripts: preinitScripts,
|
|
2662
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
2663
2662
|
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
2664
2663
|
nonce: nonce,
|
|
2665
2664
|
images: ctx.renderOpts.images
|
|
@@ -2680,7 +2679,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2680
2679
|
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2681
2680
|
// We don't normally log these errors because we are going to retry anyway but
|
|
2682
2681
|
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
2683
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
2682
|
+
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
|
|
2684
2683
|
}
|
|
2685
2684
|
},
|
|
2686
2685
|
bootstrapScripts: [
|
|
@@ -2701,7 +2700,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2701
2700
|
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
|
|
2702
2701
|
// We don't normally log these errors because we are going to retry anyway but
|
|
2703
2702
|
// it can be useful for debugging Next.js itself to get visibility here when needed
|
|
2704
|
-
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route);
|
|
2703
|
+
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
|
|
2705
2704
|
}
|
|
2706
2705
|
});
|
|
2707
2706
|
// This is mostly needed for dynamic `import()`s in client components.
|
|
@@ -2769,7 +2768,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2769
2768
|
const pendingPrerenderResult = _workunitasyncstorageexternal.workUnitAsyncStorage.run(// The store to scope
|
|
2770
2769
|
finalServerPrerenderStore, // The function to run
|
|
2771
2770
|
ComponentMod.prerender, // ... the arguments for the function to run
|
|
2772
|
-
finalAttemptRSCPayload,
|
|
2771
|
+
finalAttemptRSCPayload, clientModules, {
|
|
2773
2772
|
filterStackFrame,
|
|
2774
2773
|
onError: (err)=>{
|
|
2775
2774
|
return serverComponentsErrorHandler(err);
|
|
@@ -2833,8 +2832,8 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2833
2832
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
2834
2833
|
reactServerStream: reactServerResult.asUnclosingStream(),
|
|
2835
2834
|
reactDebugStream: undefined,
|
|
2835
|
+
debugEndTime: undefined,
|
|
2836
2836
|
preinitScripts: preinitScripts,
|
|
2837
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
2838
2837
|
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
2839
2838
|
nonce: nonce,
|
|
2840
2839
|
images: ctx.renderOpts.images
|
|
@@ -2941,8 +2940,8 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2941
2940
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
2942
2941
|
reactServerStream: foreverStream,
|
|
2943
2942
|
reactDebugStream: undefined,
|
|
2943
|
+
debugEndTime: undefined,
|
|
2944
2944
|
preinitScripts: ()=>{},
|
|
2945
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
2946
2945
|
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
2947
2946
|
nonce: nonce,
|
|
2948
2947
|
images: ctx.renderOpts.images
|
|
@@ -2973,7 +2972,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
2973
2972
|
// TODO: In the future, rather than defer the entire hydration payload
|
|
2974
2973
|
// to be fetched by the client, we should only defer the client
|
|
2975
2974
|
// segments, since those are the only ones whose data is not complete.
|
|
2976
|
-
const emptyReactServerResult = await (0, _apprenderprerenderutils.createReactServerPrerenderResultFromRender)(ComponentMod.renderToReadableStream([],
|
|
2975
|
+
const emptyReactServerResult = await (0, _apprenderprerenderutils.createReactServerPrerenderResultFromRender)(ComponentMod.renderToReadableStream([], clientModules, {
|
|
2977
2976
|
filterStackFrame,
|
|
2978
2977
|
onError: serverComponentsErrorHandler
|
|
2979
2978
|
}));
|
|
@@ -3028,7 +3027,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
3028
3027
|
};
|
|
3029
3028
|
const RSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(reactServerPrerenderStore, getRSCPayload, tree, ctx, res.statusCode === 404);
|
|
3030
3029
|
const reactServerResult = reactServerPrerenderResult = await (0, _apprenderprerenderutils.createReactServerPrerenderResultFromRender)(_workunitasyncstorageexternal.workUnitAsyncStorage.run(reactServerPrerenderStore, ComponentMod.renderToReadableStream, // ... the arguments for the function to run
|
|
3031
|
-
RSCPayload,
|
|
3030
|
+
RSCPayload, clientModules, {
|
|
3032
3031
|
filterStackFrame,
|
|
3033
3032
|
onError: serverComponentsErrorHandler
|
|
3034
3033
|
}));
|
|
@@ -3052,8 +3051,8 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
3052
3051
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
3053
3052
|
reactServerStream: reactServerResult.asUnclosingStream(),
|
|
3054
3053
|
reactDebugStream: undefined,
|
|
3054
|
+
debugEndTime: undefined,
|
|
3055
3055
|
preinitScripts: preinitScripts,
|
|
3056
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
3057
3056
|
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
3058
3057
|
nonce: nonce,
|
|
3059
3058
|
images: ctx.renderOpts.images
|
|
@@ -3165,8 +3164,8 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
3165
3164
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
3166
3165
|
reactServerStream: foreverStream,
|
|
3167
3166
|
reactDebugStream: undefined,
|
|
3167
|
+
debugEndTime: undefined,
|
|
3168
3168
|
preinitScripts: ()=>{},
|
|
3169
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
3170
3169
|
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
3171
3170
|
nonce: nonce,
|
|
3172
3171
|
images: ctx.renderOpts.images
|
|
@@ -3212,7 +3211,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
3212
3211
|
// This is a regular static generation. We don't do dynamic tracking because we rely on
|
|
3213
3212
|
// the old-school dynamic error handling to bail out of static generation
|
|
3214
3213
|
const RSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(prerenderLegacyStore, getRSCPayload, tree, ctx, res.statusCode === 404);
|
|
3215
|
-
const reactServerResult = reactServerPrerenderResult = await (0, _apprenderprerenderutils.createReactServerPrerenderResultFromRender)(_workunitasyncstorageexternal.workUnitAsyncStorage.run(prerenderLegacyStore, ComponentMod.renderToReadableStream, RSCPayload,
|
|
3214
|
+
const reactServerResult = reactServerPrerenderResult = await (0, _apprenderprerenderutils.createReactServerPrerenderResultFromRender)(_workunitasyncstorageexternal.workUnitAsyncStorage.run(prerenderLegacyStore, ComponentMod.renderToReadableStream, RSCPayload, clientModules, {
|
|
3216
3215
|
filterStackFrame,
|
|
3217
3216
|
onError: serverComponentsErrorHandler
|
|
3218
3217
|
}));
|
|
@@ -3221,8 +3220,8 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
3221
3220
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(App, {
|
|
3222
3221
|
reactServerStream: reactServerResult.asUnclosingStream(),
|
|
3223
3222
|
reactDebugStream: undefined,
|
|
3223
|
+
debugEndTime: undefined,
|
|
3224
3224
|
preinitScripts: preinitScripts,
|
|
3225
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
3226
3225
|
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
3227
3226
|
nonce: nonce,
|
|
3228
3227
|
images: ctx.renderOpts.images
|
|
@@ -3315,7 +3314,7 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
3315
3314
|
]
|
|
3316
3315
|
};
|
|
3317
3316
|
const errorRSCPayload = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(prerenderLegacyStore, getErrorRSCPayload, tree, ctx, reactServerErrorsByDigest.has(err.digest) ? undefined : err, errorType);
|
|
3318
|
-
const errorServerStream = _workunitasyncstorageexternal.workUnitAsyncStorage.run(prerenderLegacyStore, ComponentMod.renderToReadableStream, errorRSCPayload,
|
|
3317
|
+
const errorServerStream = _workunitasyncstorageexternal.workUnitAsyncStorage.run(prerenderLegacyStore, ComponentMod.renderToReadableStream, errorRSCPayload, clientModules, {
|
|
3319
3318
|
filterStackFrame,
|
|
3320
3319
|
onError: serverComponentsErrorHandler
|
|
3321
3320
|
});
|
|
@@ -3328,10 +3327,8 @@ async function prerenderToStream(req, res, ctx, metadata, tree, fallbackRoutePar
|
|
|
3328
3327
|
element: // eslint-disable-next-line @next/internal/no-ambiguous-jsx
|
|
3329
3328
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(ErrorApp, {
|
|
3330
3329
|
reactServerStream: errorServerStream,
|
|
3331
|
-
reactDebugStream: undefined,
|
|
3332
3330
|
ServerInsertedHTMLProvider: ServerInsertedHTMLProvider,
|
|
3333
3331
|
preinitScripts: errorPreinitScripts,
|
|
3334
|
-
clientReferenceManifest: clientReferenceManifest,
|
|
3335
3332
|
nonce: nonce,
|
|
3336
3333
|
images: ctx.renderOpts.images
|
|
3337
3334
|
}),
|
|
@@ -3440,10 +3437,7 @@ async function collectSegmentData(fullPageDataBuffer, prerenderStore, ComponentM
|
|
|
3440
3437
|
// For performance, we reuse the Flight output that was created when
|
|
3441
3438
|
// generating the initial page HTML. The Flight stream for the whole page is
|
|
3442
3439
|
// decomposed into a separate stream per segment.
|
|
3443
|
-
const
|
|
3444
|
-
if (!clientReferenceManifest) {
|
|
3445
|
-
return;
|
|
3446
|
-
}
|
|
3440
|
+
const { clientModules, edgeRscModuleMapping, rscModuleMapping } = (0, _manifestssingleton.getClientReferenceManifest)();
|
|
3447
3441
|
// Manifest passed to the Flight client for reading the full-page Flight
|
|
3448
3442
|
// stream. Based off similar code in use-cache-wrapper.ts.
|
|
3449
3443
|
const isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge';
|
|
@@ -3452,12 +3446,12 @@ async function collectSegmentData(fullPageDataBuffer, prerenderStore, ComponentM
|
|
|
3452
3446
|
// to be added to the consumer. Instead, we'll wait for any ClientReference to be emitted
|
|
3453
3447
|
// which themselves will handle the preloading.
|
|
3454
3448
|
moduleLoading: null,
|
|
3455
|
-
moduleMap: isEdgeRuntime ?
|
|
3456
|
-
serverModuleMap: (0,
|
|
3449
|
+
moduleMap: isEdgeRuntime ? edgeRscModuleMapping : rscModuleMapping,
|
|
3450
|
+
serverModuleMap: (0, _manifestssingleton.getServerModuleMap)()
|
|
3457
3451
|
};
|
|
3458
3452
|
const selectStaleTime = createSelectStaleTime(renderOpts.experimental);
|
|
3459
3453
|
const staleTime = selectStaleTime(prerenderStore.stale);
|
|
3460
|
-
return await ComponentMod.collectSegmentData(renderOpts.cacheComponents, fullPageDataBuffer, staleTime,
|
|
3454
|
+
return await ComponentMod.collectSegmentData(renderOpts.cacheComponents, fullPageDataBuffer, staleTime, clientModules, serverConsumerManifest);
|
|
3461
3455
|
}
|
|
3462
3456
|
function isBypassingCachesInDev(renderOpts, requestStore) {
|
|
3463
3457
|
return process.env.NODE_ENV === 'development' && !!renderOpts.dev && requestStore.headers.get('cache-control') === 'no-cache';
|
|
@@ -3466,5 +3460,67 @@ function WarnForBypassCachesInDev({ route }) {
|
|
|
3466
3460
|
(0, _warnonce.warnOnce)(`Route ${route} is rendering with server caches disabled. For this navigation, Component Metadata in React DevTools will not accurately reflect what is statically prerenderable and runtime prefetchable. See more info here: https://nextjs.org/docs/messages/cache-bypass-in-dev`);
|
|
3467
3461
|
return null;
|
|
3468
3462
|
}
|
|
3463
|
+
function nodeStreamFromReadableStream(stream) {
|
|
3464
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
3465
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('nodeStreamFromReadableStream cannot be used in the edge runtime'), "__NEXT_ERROR_CODE", {
|
|
3466
|
+
value: "E944",
|
|
3467
|
+
enumerable: false,
|
|
3468
|
+
configurable: true
|
|
3469
|
+
});
|
|
3470
|
+
} else {
|
|
3471
|
+
const reader = stream.getReader();
|
|
3472
|
+
const { Readable } = require('node:stream');
|
|
3473
|
+
return new Readable({
|
|
3474
|
+
read () {
|
|
3475
|
+
reader.read().then(({ done, value })=>{
|
|
3476
|
+
if (done) {
|
|
3477
|
+
this.push(null);
|
|
3478
|
+
} else {
|
|
3479
|
+
this.push(value);
|
|
3480
|
+
}
|
|
3481
|
+
}).catch((err)=>this.destroy(err));
|
|
3482
|
+
}
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
function createNodeStreamFromChunks(partialChunks, allChunks, signal) {
|
|
3487
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
3488
|
+
throw Object.defineProperty(new _invarianterror.InvariantError('createNodeStreamFromChunks cannot be used in the edge runtime'), "__NEXT_ERROR_CODE", {
|
|
3489
|
+
value: "E945",
|
|
3490
|
+
enumerable: false,
|
|
3491
|
+
configurable: true
|
|
3492
|
+
});
|
|
3493
|
+
} else {
|
|
3494
|
+
const { Readable } = require('node:stream');
|
|
3495
|
+
let nextIndex = 0;
|
|
3496
|
+
const readable = new Readable({
|
|
3497
|
+
read () {
|
|
3498
|
+
while(nextIndex < partialChunks.length){
|
|
3499
|
+
this.push(partialChunks[nextIndex]);
|
|
3500
|
+
nextIndex++;
|
|
3501
|
+
}
|
|
3502
|
+
}
|
|
3503
|
+
});
|
|
3504
|
+
signal.addEventListener('abort', ()=>{
|
|
3505
|
+
// Flush any remaining chunks from the original set
|
|
3506
|
+
while(nextIndex < partialChunks.length){
|
|
3507
|
+
readable.push(partialChunks[nextIndex]);
|
|
3508
|
+
nextIndex++;
|
|
3509
|
+
}
|
|
3510
|
+
// Flush all chunks since we're now aborted and can't schedule
|
|
3511
|
+
// any new work but these chunks might unblock debugInfo
|
|
3512
|
+
while(nextIndex < allChunks.length){
|
|
3513
|
+
readable.push(allChunks[nextIndex]);
|
|
3514
|
+
nextIndex++;
|
|
3515
|
+
}
|
|
3516
|
+
setImmediate(()=>{
|
|
3517
|
+
readable.push(null);
|
|
3518
|
+
});
|
|
3519
|
+
}, {
|
|
3520
|
+
once: true
|
|
3521
|
+
});
|
|
3522
|
+
return readable;
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3469
3525
|
|
|
3470
3526
|
//# sourceMappingURL=app-render.js.map
|