next 15.4.0-canary.42 → 15.4.0-canary.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +2 -2
  3. package/dist/build/swc/index.js +1 -1
  4. package/dist/build/utils.d.ts +1 -0
  5. package/dist/build/utils.js +9 -0
  6. package/dist/build/utils.js.map +1 -1
  7. package/dist/build/webpack-config.js +20 -4
  8. package/dist/build/webpack-config.js.map +1 -1
  9. package/dist/client/app-bootstrap.js +1 -1
  10. package/dist/client/index.js +1 -1
  11. package/dist/compiled/next-server/pages-turbo.runtime.dev.js +2 -2
  12. package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
  13. package/dist/compiled/next-server/pages-turbo.runtime.prod.js +2 -2
  14. package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
  15. package/dist/compiled/next-server/pages.runtime.dev.js +2 -2
  16. package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
  17. package/dist/compiled/next-server/pages.runtime.prod.js +2 -2
  18. package/dist/compiled/next-server/pages.runtime.prod.js.map +1 -1
  19. package/dist/compiled/next-server/server.runtime.prod.js +1 -1
  20. package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
  21. package/dist/esm/build/index.js +2 -2
  22. package/dist/esm/build/swc/index.js +1 -1
  23. package/dist/esm/build/utils.js +5 -0
  24. package/dist/esm/build/utils.js.map +1 -1
  25. package/dist/esm/build/webpack-config.js +21 -5
  26. package/dist/esm/build/webpack-config.js.map +1 -1
  27. package/dist/esm/client/app-bootstrap.js +1 -1
  28. package/dist/esm/client/index.js +1 -1
  29. package/dist/esm/server/base-server.js +1 -1
  30. package/dist/esm/server/base-server.js.map +1 -1
  31. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  32. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  33. package/dist/esm/server/lib/app-info-log.js +1 -1
  34. package/dist/esm/server/lib/start-server.js +1 -1
  35. package/dist/esm/server/typescript/rules/client-boundary.js +2 -1
  36. package/dist/esm/server/typescript/rules/client-boundary.js.map +1 -1
  37. package/dist/esm/server/web/adapter.js +4 -1
  38. package/dist/esm/server/web/adapter.js.map +1 -1
  39. package/dist/esm/server/web/sandbox/sandbox.js +1 -0
  40. package/dist/esm/server/web/sandbox/sandbox.js.map +1 -1
  41. package/dist/esm/shared/lib/canary-only.js +1 -1
  42. package/dist/server/base-server.js +1 -1
  43. package/dist/server/base-server.js.map +1 -1
  44. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  45. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  46. package/dist/server/lib/app-info-log.js +1 -1
  47. package/dist/server/lib/start-server.js +1 -1
  48. package/dist/server/typescript/rules/client-boundary.js +2 -1
  49. package/dist/server/typescript/rules/client-boundary.js.map +1 -1
  50. package/dist/server/web/adapter.js +4 -1
  51. package/dist/server/web/adapter.js.map +1 -1
  52. package/dist/server/web/sandbox/sandbox.js +1 -0
  53. package/dist/server/web/sandbox/sandbox.js.map +1 -1
  54. package/dist/shared/lib/canary-only.js +1 -1
  55. package/dist/telemetry/anonymous-meta.js +1 -1
  56. package/dist/telemetry/events/session-stopped.js +2 -2
  57. package/dist/telemetry/events/version.js +2 -2
  58. package/package.json +15 -15
@@ -83,7 +83,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
83
83
  }
84
84
  const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
85
85
  const hotReloaderSpan = trace('hot-reloader', undefined, {
86
- version: "15.4.0-canary.42"
86
+ version: "15.4.0-canary.43"
87
87
  });
88
88
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
89
89
  // of the current `next dev` invocation.
@@ -181,7 +181,7 @@ export default class HotReloaderWebpack {
181
181
  this.previewProps = previewProps;
182
182
  this.rewrites = rewrites;
183
183
  this.hotReloaderSpan = trace('hot-reloader', undefined, {
184
- version: "15.4.0-canary.42"
184
+ version: "15.4.0-canary.43"
185
185
  });
186
186
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
187
187
  // of the current `next dev` invocation.
@@ -12,7 +12,7 @@ export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures
12
12
  } else {
13
13
  bundlerSuffix = '';
14
14
  }
15
- Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.4.0-canary.42"}`))}${bundlerSuffix}`);
15
+ Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.4.0-canary.43"}`))}${bundlerSuffix}`);
16
16
  if (appUrl) {
17
17
  Log.bootstrap(`- Local: ${appUrl}`);
18
18
  }
@@ -42,7 +42,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
42
42
  export async function startServer(serverOptions) {
43
43
  const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
44
44
  let { port } = serverOptions;
45
- process.title = `next-server (v${"15.4.0-canary.42"})`;
45
+ process.title = `next-server (v${"15.4.0-canary.43"})`;
46
46
  let handlersReady = ()=>{};
47
47
  let handlersError = ()=>{};
48
48
  let handlersPromise = new Promise((resolve, reject)=>{
@@ -38,7 +38,8 @@ const clientBoundary = {
38
38
  const propTypeInfo = typeChecker.getTypeAtLocation(propType);
39
39
  const typeDeclarationNode = (_propTypeInfo_symbol = propTypeInfo.symbol) == null ? void 0 : (_propTypeInfo_symbol_getDeclarations = _propTypeInfo_symbol.getDeclarations()) == null ? void 0 : _propTypeInfo_symbol_getDeclarations[0];
40
40
  if (typeDeclarationNode) {
41
- if (ts.isFunctionTypeNode(typeDeclarationNode)) {
41
+ if (ts.isFunctionTypeNode(typeDeclarationNode) || // someFunc(): void
42
+ ts.isMethodSignature(typeDeclarationNode)) {
42
43
  // By convention, props named "action" can accept functions since we
43
44
  // assume these are Server Actions. Structurally, there's no
44
45
  // difference between a Server Action and a normal function until
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/server/typescript/rules/client-boundary.ts"],"sourcesContent":["// This module provides intellisense for all components that has the `\"use client\"` directive.\n\nimport { NEXT_TS_ERRORS } from '../constant'\nimport { getTs, getTypeChecker } from '../utils'\nimport type tsModule from 'typescript/lib/tsserverlibrary'\n\nconst clientBoundary = {\n getSemanticDiagnosticsForExportVariableStatement(\n source: tsModule.SourceFile,\n node: tsModule.VariableStatement\n ) {\n const ts = getTs()\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n if (ts.isVariableDeclarationList(node.declarationList)) {\n for (const declaration of node.declarationList.declarations) {\n const initializer = declaration.initializer\n if (initializer && ts.isArrowFunction(initializer)) {\n diagnostics.push(\n ...clientBoundary.getSemanticDiagnosticsForFunctionExport(\n source,\n initializer\n )\n )\n }\n }\n }\n\n return diagnostics\n },\n\n getSemanticDiagnosticsForFunctionExport(\n source: tsModule.SourceFile,\n node: tsModule.FunctionDeclaration | tsModule.ArrowFunction\n ) {\n const ts = getTs()\n const typeChecker = getTypeChecker()\n if (!typeChecker) return []\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n const isErrorFile = /[\\\\/]error\\.tsx?$/.test(source.fileName)\n const isGlobalErrorFile = /[\\\\/]global-error\\.tsx?$/.test(source.fileName)\n\n const props = node.parameters?.[0]\n if (props) {\n const propsType = typeChecker.getTypeAtLocation(props)\n const typeNode = propsType.symbol?.getDeclarations()?.[0]\n\n if (typeNode && ts.isTypeLiteralNode(typeNode)) {\n for (const member of typeNode.members) {\n if (ts.isPropertySignature(member)) {\n const propName = member.name.getText()\n const propType = member.type\n\n if (propType) {\n const propTypeInfo = typeChecker.getTypeAtLocation(propType)\n const typeDeclarationNode =\n propTypeInfo.symbol?.getDeclarations()?.[0]\n\n if (typeDeclarationNode) {\n if (ts.isFunctionTypeNode(typeDeclarationNode)) {\n // By convention, props named \"action\" can accept functions since we\n // assume these are Server Actions. Structurally, there's no\n // difference between a Server Action and a normal function until\n // TypeScript exposes directives in the type of a function. This\n // will miss accidentally passing normal functions but a false\n // negative is better than a false positive given how frequent the\n // false-positive would be.\n const maybeServerAction =\n propName === 'action' || /.+Action$/.test(propName)\n\n // There's a special case for the error file that the `reset` prop\n // is allowed to be a function:\n // https://github.com/vercel/next.js/issues/46573\n const isErrorReset =\n (isErrorFile || isGlobalErrorFile) && propName === 'reset'\n\n if (!maybeServerAction && !isErrorReset) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Warning,\n code: NEXT_TS_ERRORS.INVALID_CLIENT_ENTRY_PROP,\n messageText:\n `Props must be serializable for components in the \"use client\" entry file. ` +\n `\"${propName}\" is a function that's not a Server Action. ` +\n `Rename \"${propName}\" either to \"action\" or have its name end with \"Action\" e.g. \"${propName}Action\" to indicate it is a Server Action.`,\n start: propType.getStart(),\n length: propType.getWidth(),\n })\n }\n } else if (\n // Show warning for not serializable props.\n ts.isConstructorTypeNode(typeDeclarationNode) ||\n ts.isClassDeclaration(typeDeclarationNode)\n ) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Warning,\n code: NEXT_TS_ERRORS.INVALID_CLIENT_ENTRY_PROP,\n messageText: `Props must be serializable for components in the \"use client\" entry file, \"${propName}\" is invalid.`,\n start: propType.getStart(),\n length: propType.getWidth(),\n })\n }\n }\n }\n }\n }\n }\n }\n\n return diagnostics\n },\n}\n\nexport default clientBoundary\n"],"names":["NEXT_TS_ERRORS","getTs","getTypeChecker","clientBoundary","getSemanticDiagnosticsForExportVariableStatement","source","node","ts","diagnostics","isVariableDeclarationList","declarationList","declaration","declarations","initializer","isArrowFunction","push","getSemanticDiagnosticsForFunctionExport","typeChecker","isErrorFile","test","fileName","isGlobalErrorFile","props","parameters","propsType","getTypeAtLocation","typeNode","symbol","getDeclarations","isTypeLiteralNode","member","members","isPropertySignature","propName","name","getText","propType","type","propTypeInfo","typeDeclarationNode","isFunctionTypeNode","maybeServerAction","isErrorReset","file","category","DiagnosticCategory","Warning","code","INVALID_CLIENT_ENTRY_PROP","messageText","start","getStart","length","getWidth","isConstructorTypeNode","isClassDeclaration"],"mappings":"AAAA,8FAA8F;AAE9F,SAASA,cAAc,QAAQ,cAAa;AAC5C,SAASC,KAAK,EAAEC,cAAc,QAAQ,WAAU;AAGhD,MAAMC,iBAAiB;IACrBC,kDACEC,MAA2B,EAC3BC,IAAgC;QAEhC,MAAMC,KAAKN;QAEX,MAAMO,cAAqC,EAAE;QAE7C,IAAID,GAAGE,yBAAyB,CAACH,KAAKI,eAAe,GAAG;YACtD,KAAK,MAAMC,eAAeL,KAAKI,eAAe,CAACE,YAAY,CAAE;gBAC3D,MAAMC,cAAcF,YAAYE,WAAW;gBAC3C,IAAIA,eAAeN,GAAGO,eAAe,CAACD,cAAc;oBAClDL,YAAYO,IAAI,IACXZ,eAAea,uCAAuC,CACvDX,QACAQ;gBAGN;YACF;QACF;QAEA,OAAOL;IACT;IAEAQ,yCACEX,MAA2B,EAC3BC,IAA2D;YAW7CA;QATd,MAAMC,KAAKN;QACX,MAAMgB,cAAcf;QACpB,IAAI,CAACe,aAAa,OAAO,EAAE;QAE3B,MAAMT,cAAqC,EAAE;QAE7C,MAAMU,cAAc,oBAAoBC,IAAI,CAACd,OAAOe,QAAQ;QAC5D,MAAMC,oBAAoB,2BAA2BF,IAAI,CAACd,OAAOe,QAAQ;QAEzE,MAAME,SAAQhB,mBAAAA,KAAKiB,UAAU,qBAAfjB,gBAAiB,CAAC,EAAE;QAClC,IAAIgB,OAAO;gBAEQE,mCAAAA;YADjB,MAAMA,YAAYP,YAAYQ,iBAAiB,CAACH;YAChD,MAAMI,YAAWF,oBAAAA,UAAUG,MAAM,sBAAhBH,oCAAAA,kBAAkBI,eAAe,uBAAjCJ,iCAAqC,CAAC,EAAE;YAEzD,IAAIE,YAAYnB,GAAGsB,iBAAiB,CAACH,WAAW;gBAC9C,KAAK,MAAMI,UAAUJ,SAASK,OAAO,CAAE;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kB,CAACC,OAAO;wCACvCC,MAAM/C,eAAegD,yBAAyB;wCAC9CC,aAAa,CAAC,2EAA2E,EAAEhB,SAAS,aAAa,CAAC;wCAClHiB,OAAOd,SAASe,QAAQ;wCACxBC,QAAQhB,SAASiB,QAAQ;oCAC3B;gCACF;4BACF;wBACF;oBACF;gBACF;YACF;QACF;QAEA,OAAO7C;IACT;AACF;AAEA,eAAeL,eAAc","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/server/typescript/rules/client-boundary.ts"],"sourcesContent":["// This module provides intellisense for all components that has the `\"use client\"` directive.\n\nimport { NEXT_TS_ERRORS } from '../constant'\nimport { getTs, getTypeChecker } from '../utils'\nimport type tsModule from 'typescript/lib/tsserverlibrary'\n\nconst clientBoundary = {\n getSemanticDiagnosticsForExportVariableStatement(\n source: tsModule.SourceFile,\n node: tsModule.VariableStatement\n ) {\n const ts = getTs()\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n if (ts.isVariableDeclarationList(node.declarationList)) {\n for (const declaration of node.declarationList.declarations) {\n const initializer = declaration.initializer\n if (initializer && ts.isArrowFunction(initializer)) {\n diagnostics.push(\n ...clientBoundary.getSemanticDiagnosticsForFunctionExport(\n source,\n initializer\n )\n )\n }\n }\n }\n\n return diagnostics\n },\n\n getSemanticDiagnosticsForFunctionExport(\n source: tsModule.SourceFile,\n node: tsModule.FunctionDeclaration | tsModule.ArrowFunction\n ) {\n const ts = getTs()\n const typeChecker = getTypeChecker()\n if (!typeChecker) return []\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n const isErrorFile = /[\\\\/]error\\.tsx?$/.test(source.fileName)\n const isGlobalErrorFile = /[\\\\/]global-error\\.tsx?$/.test(source.fileName)\n\n const props = node.parameters?.[0]\n if (props) {\n const propsType = typeChecker.getTypeAtLocation(props)\n const typeNode = propsType.symbol?.getDeclarations()?.[0]\n\n if (typeNode && ts.isTypeLiteralNode(typeNode)) {\n for (const member of typeNode.members) {\n if (ts.isPropertySignature(member)) {\n const propName = member.name.getText()\n const propType = member.type\n\n if (propType) {\n const propTypeInfo = typeChecker.getTypeAtLocation(propType)\n const typeDeclarationNode =\n propTypeInfo.symbol?.getDeclarations()?.[0]\n\n if (typeDeclarationNode) {\n if (\n ts.isFunctionTypeNode(typeDeclarationNode) ||\n // someFunc(): void\n ts.isMethodSignature(typeDeclarationNode)\n ) {\n // By convention, props named \"action\" can accept functions since we\n // assume these are Server Actions. Structurally, there's no\n // difference between a Server Action and a normal function until\n // TypeScript exposes directives in the type of a function. This\n // will miss accidentally passing normal functions but a false\n // negative is better than a false positive given how frequent the\n // false-positive would be.\n const maybeServerAction =\n propName === 'action' || /.+Action$/.test(propName)\n\n // There's a special case for the error file that the `reset` prop\n // is allowed to be a function:\n // https://github.com/vercel/next.js/issues/46573\n const isErrorReset =\n (isErrorFile || isGlobalErrorFile) && propName === 'reset'\n\n if (!maybeServerAction && !isErrorReset) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Warning,\n code: NEXT_TS_ERRORS.INVALID_CLIENT_ENTRY_PROP,\n messageText:\n `Props must be serializable for components in the \"use client\" entry file. ` +\n `\"${propName}\" is a function that's not a Server Action. ` +\n `Rename \"${propName}\" either to \"action\" or have its name end with \"Action\" e.g. \"${propName}Action\" to indicate it is a Server Action.`,\n start: propType.getStart(),\n length: propType.getWidth(),\n })\n }\n } else if (\n // Show warning for not serializable props.\n ts.isConstructorTypeNode(typeDeclarationNode) ||\n ts.isClassDeclaration(typeDeclarationNode)\n ) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Warning,\n code: NEXT_TS_ERRORS.INVALID_CLIENT_ENTRY_PROP,\n messageText: `Props must be serializable for components in the \"use client\" entry file, \"${propName}\" is invalid.`,\n start: propType.getStart(),\n length: propType.getWidth(),\n })\n }\n }\n }\n }\n }\n }\n }\n\n return diagnostics\n },\n}\n\nexport default clientBoundary\n"],"names":["NEXT_TS_ERRORS","getTs","getTypeChecker","clientBoundary","getSemanticDiagnosticsForExportVariableStatement","source","node","ts","diagnostics","isVariableDeclarationList","declarationList","declaration","declarations","initializer","isArrowFunction","push","getSemanticDiagnosticsForFunctionExport","typeChecker","isErrorFile","test","fileName","isGlobalErrorFile","props","parameters","propsType","getTypeAtLocation","typeNode","symbol","getDeclarations","isTypeLiteralNode","member","members","isPropertySignature","propName","name","getText","propType","type","propTypeInfo","typeDeclarationNode","isFunctionTypeNode","isMethodSignature","maybeServerAction","isErrorReset","file","category","DiagnosticCategory","Warning","code","INVALID_CLIENT_ENTRY_PROP","messageText","start","getStart","length","getWidth","isConstructorTypeNode","isClassDeclaration"],"mappings":"AAAA,8FAA8F;AAE9F,SAASA,cAAc,QAAQ,cAAa;AAC5C,SAASC,KAAK,EAAEC,cAAc,QAAQ,WAAU;AAGhD,MAAMC,iBAAiB;IACrBC,kDACEC,MAA2B,EAC3BC,IAAgC;QAEhC,MAAMC,KAAKN;QAEX,MAAMO,cAAqC,EAAE;QAE7C,IAAID,GAAGE,yBAAyB,CAACH,KAAKI,eAAe,GAAG;YACtD,KAAK,MAAMC,eAAeL,KAAKI,eAAe,CAACE,YAAY,CAAE;gBAC3D,MAAMC,cAAcF,YAAYE,WAAW;gBAC3C,IAAIA,eAAeN,GAAGO,eAAe,CAACD,cAAc;oBAClDL,YAAYO,IAAI,IACXZ,eAAea,uCAAuC,CACvDX,QACAQ;gBAGN;YACF;QACF;QAEA,OAAOL;IACT;IAEAQ,yCACEX,MAA2B,EAC3BC,IAA2D;YAW7CA;QATd,MAAMC,KAAKN;QACX,MAAMgB,cAAcf;QACpB,IAAI,CAACe,aAAa,OAAO,EAAE;QAE3B,MAAMT,cAAqC,EAAE;QAE7C,MAAMU,cAAc,oBAAoBC,IAAI,CAACd,OAAOe,QAAQ;QAC5D,MAAMC,oBAAoB,2BAA2BF,IAAI,CAACd,OAAOe,QAAQ;QAEzE,MAAME,SAAQhB,mBAAAA,KAAKiB,UAAU,qBAAfjB,gBAAiB,CAAC,EAAE;QAClC,IAAIgB,OAAO;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AAC,QAAQ,EAAEA,SAAS,8DAA8D,EAAEA,SAAS,0CAA0C,CAAC;4CAC1IkB,OAAOf,SAASgB,QAAQ;4CACxBC,QAAQjB,SAASkB,QAAQ;wCAC3B;oCACF;gCACF,OAAO,IACL,2CAA2C;gCAC3C/C,GAAGgD,qBAAqB,CAAChB,wBACzBhC,GAAGiD,kBAAkB,CAACjB,sBACtB;oCACA/B,YAAYO,IAAI,CAAC;wCACf6B,MAAMvC;wCACNwC,UAAUtC,GAAGuC,kBAAkB,CAACC,OAAO;wCACvCC,MAAMhD,eAAeiD,yBAAyB;wCAC9CC,aAAa,CAAC,2EAA2E,EAAEjB,SAAS,aAAa,CAAC;wCAClHkB,OAAOf,SAASgB,QAAQ;wCACxBC,QAAQjB,SAASkB,QAAQ;oCAC3B;gCACF;4BACF;wBACF;oBACF;gBACF;YACF;QACF;QAEA,OAAO9C;IACT;AACF;AAEA,eAAeL,eAAc","ignoreList":[0]}
@@ -143,7 +143,10 @@ export async function adapter(params) {
143
143
  value: true
144
144
  });
145
145
  }
146
- if (!globalThis.__incrementalCache && params.IncrementalCache) {
146
+ if (// If we are inside of the next start sandbox
147
+ // leverage the shared instance if not we need
148
+ // to create a fresh cache instance each time
149
+ !globalThis.__incrementalCacheShared && params.IncrementalCache) {
147
150
  ;
148
151
  globalThis.__incrementalCache = new params.IncrementalCache({
149
152
  appDir: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/web/adapter.ts"],"sourcesContent":["import type { RequestData, FetchEventResult } from './types'\nimport type { RequestInit } from './spec-extension/request'\nimport { PageSignatureError } from './error'\nimport { fromNodeOutgoingHttpHeaders, normalizeNextQueryParam } from './utils'\nimport {\n NextFetchEvent,\n getWaitUntilPromiseFromEvent,\n} from './spec-extension/fetch-event'\nimport { NextRequest } from './spec-extension/request'\nimport { NextResponse } from './spec-extension/response'\nimport {\n parseRelativeURL,\n getRelativeURL,\n} from '../../shared/lib/router/utils/relativize-url'\nimport { NextURL } from './next-url'\nimport { stripInternalSearchParams } from '../internal-utils'\nimport { normalizeRscURL } from '../../shared/lib/router/utils/app-paths'\nimport {\n FLIGHT_HEADERS,\n NEXT_REWRITTEN_PATH_HEADER,\n NEXT_REWRITTEN_QUERY_HEADER,\n RSC_HEADER,\n} from '../../client/components/app-router-headers'\nimport { ensureInstrumentationRegistered } from './globals'\nimport { createRequestStoreForAPI } from '../async-storage/request-store'\nimport { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'\nimport { createWorkStore } from '../async-storage/work-store'\nimport { workAsyncStorage } from '../app-render/work-async-storage.external'\nimport { NEXT_ROUTER_PREFETCH_HEADER } from '../../client/components/app-router-headers'\nimport { getTracer } from '../lib/trace/tracer'\nimport type { TextMapGetter } from 'next/dist/compiled/@opentelemetry/api'\nimport { MiddlewareSpan } from '../lib/trace/constants'\nimport { CloseController } from './web-on-close'\nimport { getEdgePreviewProps } from './get-edge-preview-props'\nimport { getBuiltinRequestContext } from '../after/builtin-request-context'\nimport { getImplicitTags } from '../lib/implicit-tags'\n\nexport class NextRequestHint extends NextRequest {\n sourcePage: string\n fetchMetrics: FetchEventResult['fetchMetrics'] | undefined\n\n constructor(params: {\n init: RequestInit\n input: Request | string\n page: string\n }) {\n super(params.input, params.init)\n this.sourcePage = params.page\n }\n\n get request() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n\n respondWith() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n\n waitUntil() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n}\n\nconst headersGetter: TextMapGetter<Headers> = {\n keys: (headers) => Array.from(headers.keys()),\n get: (headers, key) => headers.get(key) ?? undefined,\n}\n\nexport type AdapterOptions = {\n handler: (req: NextRequestHint, event: NextFetchEvent) => Promise<Response>\n page: string\n request: RequestData\n IncrementalCache?: typeof import('../lib/incremental-cache').IncrementalCache\n}\n\nlet propagator: <T>(request: NextRequestHint, fn: () => T) => T = (\n request,\n fn\n) => {\n const tracer = getTracer()\n return tracer.withPropagatedContext(request.headers, fn, headersGetter)\n}\n\nlet testApisIntercepted = false\n\nfunction ensureTestApisIntercepted() {\n if (!testApisIntercepted) {\n testApisIntercepted = true\n if (process.env.NEXT_PRIVATE_TEST_PROXY === 'true') {\n const {\n interceptTestApis,\n wrapRequestHandler,\n } = require('next/dist/experimental/testmode/server-edge')\n interceptTestApis()\n propagator = wrapRequestHandler(propagator)\n }\n }\n}\n\nexport async function adapter(\n params: AdapterOptions\n): Promise<FetchEventResult> {\n ensureTestApisIntercepted()\n await ensureInstrumentationRegistered()\n\n // TODO-APP: use explicit marker for this\n const isEdgeRendering =\n typeof (globalThis as any).__BUILD_MANIFEST !== 'undefined'\n\n params.request.url = normalizeRscURL(params.request.url)\n\n const requestURL = new NextURL(params.request.url, {\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n // Iterator uses an index to keep track of the current iteration. Because of deleting and appending below we can't just use the iterator.\n // Instead we use the keys before iteration.\n const keys = [...requestURL.searchParams.keys()]\n for (const key of keys) {\n const value = requestURL.searchParams.getAll(key)\n\n const normalizedKey = normalizeNextQueryParam(key)\n if (normalizedKey) {\n requestURL.searchParams.delete(normalizedKey)\n for (const val of value) {\n requestURL.searchParams.append(normalizedKey, val)\n }\n requestURL.searchParams.delete(key)\n }\n }\n\n // Ensure users only see page requests, never data requests.\n const buildId = requestURL.buildId\n requestURL.buildId = ''\n\n const requestHeaders = fromNodeOutgoingHttpHeaders(params.request.headers)\n const isNextDataRequest = requestHeaders.has('x-nextjs-data')\n const isRSCRequest = requestHeaders.get(RSC_HEADER) === '1'\n\n if (isNextDataRequest && requestURL.pathname === '/index') {\n requestURL.pathname = '/'\n }\n\n const flightHeaders = new Map()\n\n // Headers should only be stripped for middleware\n if (!isEdgeRendering) {\n for (const header of FLIGHT_HEADERS) {\n const key = header.toLowerCase()\n const value = requestHeaders.get(key)\n if (value !== null) {\n flightHeaders.set(key, value)\n requestHeaders.delete(key)\n }\n }\n }\n\n const normalizeURL = process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE\n ? new URL(params.request.url)\n : requestURL\n\n const request = new NextRequestHint({\n page: params.page,\n // Strip internal query parameters off the request.\n input: stripInternalSearchParams(normalizeURL).toString(),\n init: {\n body: params.request.body,\n headers: requestHeaders,\n method: params.request.method,\n nextConfig: params.request.nextConfig,\n signal: params.request.signal,\n },\n })\n\n /**\n * This allows to identify the request as a data request. The user doesn't\n * need to know about this property neither use it. We add it for testing\n * purposes.\n */\n if (isNextDataRequest) {\n Object.defineProperty(request, '__isData', {\n enumerable: false,\n value: true,\n })\n }\n\n if (\n !(globalThis as any).__incrementalCache &&\n (params as any).IncrementalCache\n ) {\n ;(globalThis as any).__incrementalCache = new (\n params as any\n ).IncrementalCache({\n appDir: true,\n fetchCache: true,\n minimalMode: process.env.NODE_ENV !== 'development',\n fetchCacheKeyPrefix: process.env.__NEXT_FETCH_CACHE_KEY_PREFIX,\n dev: process.env.NODE_ENV === 'development',\n requestHeaders: params.request.headers as any,\n requestProtocol: 'https',\n getPrerenderManifest: () => {\n return {\n version: -1 as any, // letting us know this doesn't conform to spec\n routes: {},\n dynamicRoutes: {},\n notFoundRoutes: [],\n preview: getEdgePreviewProps(),\n }\n },\n })\n }\n\n // if we're in an edge runtime sandbox, we should use the waitUntil\n // that we receive from the enclosing NextServer\n const outerWaitUntil =\n params.request.waitUntil ?? getBuiltinRequestContext()?.waitUntil\n\n const event = new NextFetchEvent({\n request,\n page: params.page,\n context: outerWaitUntil ? { waitUntil: outerWaitUntil } : undefined,\n })\n let response\n let cookiesFromResponse\n\n response = await propagator(request, () => {\n // we only care to make async storage available for middleware\n const isMiddleware =\n params.page === '/middleware' || params.page === '/src/middleware'\n\n if (isMiddleware) {\n // if we're in an edge function, we only get a subset of `nextConfig` (no `experimental`),\n // so we have to inject it via DefinePlugin.\n // in `next start` this will be passed normally (see `NextNodeServer.runMiddleware`).\n\n const waitUntil = event.waitUntil.bind(event)\n const closeController = new CloseController()\n\n return getTracer().trace(\n MiddlewareSpan.execute,\n {\n spanName: `middleware ${request.method} ${request.nextUrl.pathname}`,\n attributes: {\n 'http.target': request.nextUrl.pathname,\n 'http.method': request.method,\n },\n },\n async () => {\n try {\n const onUpdateCookies = (cookies: Array<string>) => {\n cookiesFromResponse = cookies\n }\n const previewProps = getEdgePreviewProps()\n const page = '/' // Fake Work\n const fallbackRouteParams = null\n\n const implicitTags = await getImplicitTags(\n page,\n request.nextUrl,\n fallbackRouteParams\n )\n\n const requestStore = createRequestStoreForAPI(\n request,\n request.nextUrl,\n implicitTags,\n onUpdateCookies,\n previewProps\n )\n\n const workStore = createWorkStore({\n page,\n fallbackRouteParams,\n renderOpts: {\n cacheLifeProfiles:\n params.request.nextConfig?.experimental?.cacheLife,\n experimental: {\n isRoutePPREnabled: false,\n dynamicIO: false,\n authInterrupts:\n !!params.request.nextConfig?.experimental?.authInterrupts,\n },\n supportsDynamicResponse: true,\n waitUntil,\n onClose: closeController.onClose.bind(closeController),\n onAfterTaskError: undefined,\n },\n requestEndedState: { ended: false },\n isPrefetchRequest: request.headers.has(\n NEXT_ROUTER_PREFETCH_HEADER\n ),\n buildId: buildId ?? '',\n previouslyRevalidatedTags: [],\n })\n\n return await workAsyncStorage.run(workStore, () =>\n workUnitAsyncStorage.run(\n requestStore,\n params.handler,\n request,\n event\n )\n )\n } finally {\n // middleware cannot stream, so we can consider the response closed\n // as soon as the handler returns.\n // we can delay running it until a bit later --\n // if it's needed, we'll have a `waitUntil` lock anyway.\n setTimeout(() => {\n closeController.dispatchClose()\n }, 0)\n }\n }\n )\n }\n return params.handler(request, event)\n })\n\n // check if response is a Response object\n if (response && !(response instanceof Response)) {\n throw new TypeError('Expected an instance of Response to be returned')\n }\n\n if (response && cookiesFromResponse) {\n response.headers.set('set-cookie', cookiesFromResponse)\n }\n\n /**\n * For rewrites we must always include the locale in the final pathname\n * so we re-create the NextURL forcing it to include it when the it is\n * an internal rewrite. Also we make sure the outgoing rewrite URL is\n * a data URL if the request was a data request.\n */\n const rewrite = response?.headers.get('x-middleware-rewrite')\n if (response && rewrite && (isRSCRequest || !isEdgeRendering)) {\n const destination = new NextURL(rewrite, {\n forceLocale: true,\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE && !isEdgeRendering) {\n if (destination.host === request.nextUrl.host) {\n destination.buildId = buildId || destination.buildId\n response.headers.set('x-middleware-rewrite', String(destination))\n }\n }\n\n /**\n * When the request is a data request we must show if there was a rewrite\n * with an internal header so the client knows which component to load\n * from the data request.\n */\n const { url: relativeDestination, isRelative } = parseRelativeURL(\n destination.toString(),\n requestURL.toString()\n )\n\n if (\n !isEdgeRendering &&\n isNextDataRequest &&\n // if the rewrite is external and external rewrite\n // resolving config is enabled don't add this header\n // so the upstream app can set it instead\n !(\n process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE &&\n relativeDestination.match(/http(s)?:\\/\\//)\n )\n ) {\n response.headers.set('x-nextjs-rewrite', relativeDestination)\n }\n\n // If this is an RSC request, and the pathname or search has changed, and\n // this isn't an external rewrite, we need to set the rewritten pathname and\n // query headers.\n if (isRSCRequest && isRelative) {\n if (requestURL.pathname !== destination.pathname) {\n response.headers.set(NEXT_REWRITTEN_PATH_HEADER, destination.pathname)\n }\n if (requestURL.search !== destination.search) {\n response.headers.set(\n NEXT_REWRITTEN_QUERY_HEADER,\n // remove the leading ? from the search string\n destination.search.slice(1)\n )\n }\n }\n }\n\n /**\n * For redirects we will not include the locale in case when it is the\n * default and we must also make sure the outgoing URL is a data one if\n * the incoming request was a data request.\n */\n const redirect = response?.headers.get('Location')\n if (response && redirect && !isEdgeRendering) {\n const redirectURL = new NextURL(redirect, {\n forceLocale: false,\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n /**\n * Responses created from redirects have immutable headers so we have\n * to clone the response to be able to modify it.\n */\n response = new Response(response.body, response)\n\n if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE) {\n if (redirectURL.host === requestURL.host) {\n redirectURL.buildId = buildId || redirectURL.buildId\n response.headers.set('Location', redirectURL.toString())\n }\n }\n\n /**\n * When the request is a data request we can't use the location header as\n * it may end up with CORS error. Instead we map to an internal header so\n * the client knows the destination.\n */\n if (isNextDataRequest) {\n response.headers.delete('Location')\n response.headers.set(\n 'x-nextjs-redirect',\n getRelativeURL(redirectURL.toString(), requestURL.toString())\n )\n }\n }\n\n const finalResponse = response ? response : NextResponse.next()\n\n // Flight headers are not overridable / removable so they are applied at the end.\n const middlewareOverrideHeaders = finalResponse.headers.get(\n 'x-middleware-override-headers'\n )\n const overwrittenHeaders: string[] = []\n if (middlewareOverrideHeaders) {\n for (const [key, value] of flightHeaders) {\n finalResponse.headers.set(`x-middleware-request-${key}`, value)\n overwrittenHeaders.push(key)\n }\n\n if (overwrittenHeaders.length > 0) {\n finalResponse.headers.set(\n 'x-middleware-override-headers',\n middlewareOverrideHeaders + ',' + overwrittenHeaders.join(',')\n )\n }\n }\n\n return {\n response: finalResponse,\n waitUntil: getWaitUntilPromiseFromEvent(event) ?? Promise.resolve(),\n fetchMetrics: request.fetchMetrics,\n }\n}\n"],"names":["PageSignatureError","fromNodeOutgoingHttpHeaders","normalizeNextQueryParam","NextFetchEvent","getWaitUntilPromiseFromEvent","NextRequest","NextResponse","parseRelativeURL","getRelativeURL","NextURL","stripInternalSearchParams","normalizeRscURL","FLIGHT_HEADERS","NEXT_REWRITTEN_PATH_HEADER","NEXT_REWRITTEN_QUERY_HEADER","RSC_HEADER","ensureInstrumentationRegistered","createRequestStoreForAPI","workUnitAsyncStorage","createWorkStore","workAsyncStorage","NEXT_ROUTER_PREFETCH_HEADER","getTracer","MiddlewareSpan","CloseController","getEdgePreviewProps","getBuiltinRequestContext","getImplicitTags","NextRequestHint","constructor","params","input","init","sourcePage","page","request","respondWith","waitUntil","headersGetter","keys","headers","Array","from","get","key","undefined","propagator","fn","tracer","withPropagatedContext","testApisIntercepted","ensureTestApisIntercepted","process","env","NEXT_PRIVATE_TEST_PROXY","interceptTestApis","wrapRequestHandler","require","adapter","isEdgeRendering","globalThis","__BUILD_MANIFEST","url","requestURL","nextConfig","searchParams","value","getAll","normalizedKey","delete","val","append","buildId","requestHeaders","isNextDataRequest","has","isRSCRequest","pathname","flightHeaders","Map","header","toLowerCase","set","normalizeURL","__NEXT_NO_MIDDLEWARE_URL_NORMALIZE","URL","toString","body","method","signal","Object","defineProperty","enumerable","__incrementalCache","IncrementalCache","appDir","fetchCache","minimalMode","NODE_ENV","fetchCacheKeyPrefix","__NEXT_FETCH_CACHE_KEY_PREFIX","dev","requestProtocol","getPrerenderManifest","version","routes","dynamicRoutes","notFoundRoutes","preview","outerWaitUntil","event","context","response","cookiesFromResponse","isMiddleware","bind","closeController","trace","execute","spanName","nextUrl","attributes","onUpdateCookies","cookies","previewProps","fallbackRouteParams","implicitTags","requestStore","workStore","renderOpts","cacheLifeProfiles","experimental","cacheLife","isRoutePPREnabled","dynamicIO","authInterrupts","supportsDynamicResponse","onClose","onAfterTaskError","requestEndedState","ended","isPrefetchRequest","previouslyRevalidatedTags","run","handler","setTimeout","dispatchClose","Response","TypeError","rewrite","destination","forceLocale","host","String","relativeDestination","isRelative","__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE","match","search","slice","redirect","redirectURL","finalResponse","next","middlewareOverrideHeaders","overwrittenHeaders","push","length","join","Promise","resolve","fetchMetrics"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,UAAS;AAC5C,SAASC,2BAA2B,EAAEC,uBAAuB,QAAQ,UAAS;AAC9E,SACEC,cAAc,EACdC,4BAA4B,QACvB,+BAA8B;AACrC,SAASC,WAAW,QAAQ,2BAA0B;AACtD,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SACEC,gBAAgB,EAChBC,cAAc,QACT,+CAA8C;AACrD,SAASC,OAAO,QAAQ,aAAY;AACpC,SAASC,yBAAyB,QAAQ,oBAAmB;AAC7D,SAASC,eAAe,QAAQ,0CAA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F,cAAc1H,OAAO,CAACG,GAAG,CACzD;IAEF,MAAM0H,qBAA+B,EAAE;IACvC,IAAID,2BAA2B;QAC7B,KAAK,MAAM,CAACxH,KAAKsB,MAAM,IAAIY,cAAe;YACxCoF,cAAc1H,OAAO,CAAC0C,GAAG,CAAC,CAAC,qBAAqB,EAAEtC,KAAK,EAAEsB;YACzDmG,mBAAmBC,IAAI,CAAC1H;QAC1B;QAEA,IAAIyH,mBAAmBE,MAAM,GAAG,GAAG;YACjCL,cAAc1H,OAAO,CAAC0C,GAAG,CACvB,iCACAkF,4BAA4B,MAAMC,mBAAmBG,IAAI,CAAC;QAE9D;IACF;IAEA,OAAO;QACLxD,UAAUkD;QACV7H,WAAWjC,6BAA6B0G,UAAU2D,QAAQC,OAAO;QACjEC,cAAcxI,QAAQwI,YAAY;IACpC;AACF","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../src/server/web/adapter.ts"],"sourcesContent":["import type { RequestData, FetchEventResult } from './types'\nimport type { RequestInit } from './spec-extension/request'\nimport { PageSignatureError } from './error'\nimport { fromNodeOutgoingHttpHeaders, normalizeNextQueryParam } from './utils'\nimport {\n NextFetchEvent,\n getWaitUntilPromiseFromEvent,\n} from './spec-extension/fetch-event'\nimport { NextRequest } from './spec-extension/request'\nimport { NextResponse } from './spec-extension/response'\nimport {\n parseRelativeURL,\n getRelativeURL,\n} from '../../shared/lib/router/utils/relativize-url'\nimport { NextURL } from './next-url'\nimport { stripInternalSearchParams } from '../internal-utils'\nimport { normalizeRscURL } from '../../shared/lib/router/utils/app-paths'\nimport {\n FLIGHT_HEADERS,\n NEXT_REWRITTEN_PATH_HEADER,\n NEXT_REWRITTEN_QUERY_HEADER,\n RSC_HEADER,\n} from '../../client/components/app-router-headers'\nimport { ensureInstrumentationRegistered } from './globals'\nimport { createRequestStoreForAPI } from '../async-storage/request-store'\nimport { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'\nimport { createWorkStore } from '../async-storage/work-store'\nimport { workAsyncStorage } from '../app-render/work-async-storage.external'\nimport { NEXT_ROUTER_PREFETCH_HEADER } from '../../client/components/app-router-headers'\nimport { getTracer } from '../lib/trace/tracer'\nimport type { TextMapGetter } from 'next/dist/compiled/@opentelemetry/api'\nimport { MiddlewareSpan } from '../lib/trace/constants'\nimport { CloseController } from './web-on-close'\nimport { getEdgePreviewProps } from './get-edge-preview-props'\nimport { getBuiltinRequestContext } from '../after/builtin-request-context'\nimport { getImplicitTags } from '../lib/implicit-tags'\n\nexport class NextRequestHint extends NextRequest {\n sourcePage: string\n fetchMetrics: FetchEventResult['fetchMetrics'] | undefined\n\n constructor(params: {\n init: RequestInit\n input: Request | string\n page: string\n }) {\n super(params.input, params.init)\n this.sourcePage = params.page\n }\n\n get request() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n\n respondWith() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n\n waitUntil() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n}\n\nconst headersGetter: TextMapGetter<Headers> = {\n keys: (headers) => Array.from(headers.keys()),\n get: (headers, key) => headers.get(key) ?? undefined,\n}\n\nexport type AdapterOptions = {\n handler: (req: NextRequestHint, event: NextFetchEvent) => Promise<Response>\n page: string\n request: RequestData\n IncrementalCache?: typeof import('../lib/incremental-cache').IncrementalCache\n}\n\nlet propagator: <T>(request: NextRequestHint, fn: () => T) => T = (\n request,\n fn\n) => {\n const tracer = getTracer()\n return tracer.withPropagatedContext(request.headers, fn, headersGetter)\n}\n\nlet testApisIntercepted = false\n\nfunction ensureTestApisIntercepted() {\n if (!testApisIntercepted) {\n testApisIntercepted = true\n if (process.env.NEXT_PRIVATE_TEST_PROXY === 'true') {\n const {\n interceptTestApis,\n wrapRequestHandler,\n } = require('next/dist/experimental/testmode/server-edge')\n interceptTestApis()\n propagator = wrapRequestHandler(propagator)\n }\n }\n}\n\nexport async function adapter(\n params: AdapterOptions\n): Promise<FetchEventResult> {\n ensureTestApisIntercepted()\n await ensureInstrumentationRegistered()\n\n // TODO-APP: use explicit marker for this\n const isEdgeRendering =\n typeof (globalThis as any).__BUILD_MANIFEST !== 'undefined'\n\n params.request.url = normalizeRscURL(params.request.url)\n\n const requestURL = new NextURL(params.request.url, {\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n // Iterator uses an index to keep track of the current iteration. Because of deleting and appending below we can't just use the iterator.\n // Instead we use the keys before iteration.\n const keys = [...requestURL.searchParams.keys()]\n for (const key of keys) {\n const value = requestURL.searchParams.getAll(key)\n\n const normalizedKey = normalizeNextQueryParam(key)\n if (normalizedKey) {\n requestURL.searchParams.delete(normalizedKey)\n for (const val of value) {\n requestURL.searchParams.append(normalizedKey, val)\n }\n requestURL.searchParams.delete(key)\n }\n }\n\n // Ensure users only see page requests, never data requests.\n const buildId = requestURL.buildId\n requestURL.buildId = ''\n\n const requestHeaders = fromNodeOutgoingHttpHeaders(params.request.headers)\n const isNextDataRequest = requestHeaders.has('x-nextjs-data')\n const isRSCRequest = requestHeaders.get(RSC_HEADER) === '1'\n\n if (isNextDataRequest && requestURL.pathname === '/index') {\n requestURL.pathname = '/'\n }\n\n const flightHeaders = new Map()\n\n // Headers should only be stripped for middleware\n if (!isEdgeRendering) {\n for (const header of FLIGHT_HEADERS) {\n const key = header.toLowerCase()\n const value = requestHeaders.get(key)\n if (value !== null) {\n flightHeaders.set(key, value)\n requestHeaders.delete(key)\n }\n }\n }\n\n const normalizeURL = process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE\n ? new URL(params.request.url)\n : requestURL\n\n const request = new NextRequestHint({\n page: params.page,\n // Strip internal query parameters off the request.\n input: stripInternalSearchParams(normalizeURL).toString(),\n init: {\n body: params.request.body,\n headers: requestHeaders,\n method: params.request.method,\n nextConfig: params.request.nextConfig,\n signal: params.request.signal,\n },\n })\n\n /**\n * This allows to identify the request as a data request. The user doesn't\n * need to know about this property neither use it. We add it for testing\n * purposes.\n */\n if (isNextDataRequest) {\n Object.defineProperty(request, '__isData', {\n enumerable: false,\n value: true,\n })\n }\n\n if (\n // If we are inside of the next start sandbox\n // leverage the shared instance if not we need\n // to create a fresh cache instance each time\n !(globalThis as any).__incrementalCacheShared &&\n (params as any).IncrementalCache\n ) {\n ;(globalThis as any).__incrementalCache = new (\n params as any\n ).IncrementalCache({\n appDir: true,\n fetchCache: true,\n minimalMode: process.env.NODE_ENV !== 'development',\n fetchCacheKeyPrefix: process.env.__NEXT_FETCH_CACHE_KEY_PREFIX,\n dev: process.env.NODE_ENV === 'development',\n requestHeaders: params.request.headers as any,\n requestProtocol: 'https',\n getPrerenderManifest: () => {\n return {\n version: -1 as any, // letting us know this doesn't conform to spec\n routes: {},\n dynamicRoutes: {},\n notFoundRoutes: [],\n preview: getEdgePreviewProps(),\n }\n },\n })\n }\n\n // if we're in an edge runtime sandbox, we should use the waitUntil\n // that we receive from the enclosing NextServer\n const outerWaitUntil =\n params.request.waitUntil ?? getBuiltinRequestContext()?.waitUntil\n\n const event = new NextFetchEvent({\n request,\n page: params.page,\n context: outerWaitUntil ? { waitUntil: outerWaitUntil } : undefined,\n })\n let response\n let cookiesFromResponse\n\n response = await propagator(request, () => {\n // we only care to make async storage available for middleware\n const isMiddleware =\n params.page === '/middleware' || params.page === '/src/middleware'\n\n if (isMiddleware) {\n // if we're in an edge function, we only get a subset of `nextConfig` (no `experimental`),\n // so we have to inject it via DefinePlugin.\n // in `next start` this will be passed normally (see `NextNodeServer.runMiddleware`).\n\n const waitUntil = event.waitUntil.bind(event)\n const closeController = new CloseController()\n\n return getTracer().trace(\n MiddlewareSpan.execute,\n {\n spanName: `middleware ${request.method} ${request.nextUrl.pathname}`,\n attributes: {\n 'http.target': request.nextUrl.pathname,\n 'http.method': request.method,\n },\n },\n async () => {\n try {\n const onUpdateCookies = (cookies: Array<string>) => {\n cookiesFromResponse = cookies\n }\n const previewProps = getEdgePreviewProps()\n const page = '/' // Fake Work\n const fallbackRouteParams = null\n\n const implicitTags = await getImplicitTags(\n page,\n request.nextUrl,\n fallbackRouteParams\n )\n\n const requestStore = createRequestStoreForAPI(\n request,\n request.nextUrl,\n implicitTags,\n onUpdateCookies,\n previewProps\n )\n\n const workStore = createWorkStore({\n page,\n fallbackRouteParams,\n renderOpts: {\n cacheLifeProfiles:\n params.request.nextConfig?.experimental?.cacheLife,\n experimental: {\n isRoutePPREnabled: false,\n dynamicIO: false,\n authInterrupts:\n !!params.request.nextConfig?.experimental?.authInterrupts,\n },\n supportsDynamicResponse: true,\n waitUntil,\n onClose: closeController.onClose.bind(closeController),\n onAfterTaskError: undefined,\n },\n requestEndedState: { ended: false },\n isPrefetchRequest: request.headers.has(\n NEXT_ROUTER_PREFETCH_HEADER\n ),\n buildId: buildId ?? '',\n previouslyRevalidatedTags: [],\n })\n\n return await workAsyncStorage.run(workStore, () =>\n workUnitAsyncStorage.run(\n requestStore,\n params.handler,\n request,\n event\n )\n )\n } finally {\n // middleware cannot stream, so we can consider the response closed\n // as soon as the handler returns.\n // we can delay running it until a bit later --\n // if it's needed, we'll have a `waitUntil` lock anyway.\n setTimeout(() => {\n closeController.dispatchClose()\n }, 0)\n }\n }\n )\n }\n return params.handler(request, event)\n })\n\n // check if response is a Response object\n if (response && !(response instanceof Response)) {\n throw new TypeError('Expected an instance of Response to be returned')\n }\n\n if (response && cookiesFromResponse) {\n response.headers.set('set-cookie', cookiesFromResponse)\n }\n\n /**\n * For rewrites we must always include the locale in the final pathname\n * so we re-create the NextURL forcing it to include it when the it is\n * an internal rewrite. Also we make sure the outgoing rewrite URL is\n * a data URL if the request was a data request.\n */\n const rewrite = response?.headers.get('x-middleware-rewrite')\n if (response && rewrite && (isRSCRequest || !isEdgeRendering)) {\n const destination = new NextURL(rewrite, {\n forceLocale: true,\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE && !isEdgeRendering) {\n if (destination.host === request.nextUrl.host) {\n destination.buildId = buildId || destination.buildId\n response.headers.set('x-middleware-rewrite', String(destination))\n }\n }\n\n /**\n * When the request is a data request we must show if there was a rewrite\n * with an internal header so the client knows which component to load\n * from the data request.\n */\n const { url: relativeDestination, isRelative } = parseRelativeURL(\n destination.toString(),\n requestURL.toString()\n )\n\n if (\n !isEdgeRendering &&\n isNextDataRequest &&\n // if the rewrite is external and external rewrite\n // resolving config is enabled don't add this header\n // so the upstream app can set it instead\n !(\n process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE &&\n relativeDestination.match(/http(s)?:\\/\\//)\n )\n ) {\n response.headers.set('x-nextjs-rewrite', relativeDestination)\n }\n\n // If this is an RSC request, and the pathname or search has changed, and\n // this isn't an external rewrite, we need to set the rewritten pathname and\n // query headers.\n if (isRSCRequest && isRelative) {\n if (requestURL.pathname !== destination.pathname) {\n response.headers.set(NEXT_REWRITTEN_PATH_HEADER, destination.pathname)\n }\n if (requestURL.search !== destination.search) {\n response.headers.set(\n NEXT_REWRITTEN_QUERY_HEADER,\n // remove the leading ? from the search string\n destination.search.slice(1)\n )\n }\n }\n }\n\n /**\n * For redirects we will not include the locale in case when it is the\n * default and we must also make sure the outgoing URL is a data one if\n * the incoming request was a data request.\n */\n const redirect = response?.headers.get('Location')\n if (response && redirect && !isEdgeRendering) {\n const redirectURL = new NextURL(redirect, {\n forceLocale: false,\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n /**\n * Responses created from redirects have immutable headers so we have\n * to clone the response to be able to modify it.\n */\n response = new Response(response.body, response)\n\n if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE) {\n if (redirectURL.host === requestURL.host) {\n redirectURL.buildId = buildId || redirectURL.buildId\n response.headers.set('Location', redirectURL.toString())\n }\n }\n\n /**\n * When the request is a data request we can't use the location header as\n * it may end up with CORS error. Instead we map to an internal header so\n * the client knows the destination.\n */\n if (isNextDataRequest) {\n response.headers.delete('Location')\n response.headers.set(\n 'x-nextjs-redirect',\n getRelativeURL(redirectURL.toString(), requestURL.toString())\n )\n }\n }\n\n const finalResponse = response ? response : NextResponse.next()\n\n // Flight headers are not overridable / removable so they are applied at the end.\n const middlewareOverrideHeaders = finalResponse.headers.get(\n 'x-middleware-override-headers'\n )\n const overwrittenHeaders: string[] = []\n if (middlewareOverrideHeaders) {\n for (const [key, value] of flightHeaders) {\n finalResponse.headers.set(`x-middleware-request-${key}`, value)\n overwrittenHeaders.push(key)\n }\n\n if (overwrittenHeaders.length > 0) {\n finalResponse.headers.set(\n 'x-middleware-override-headers',\n middlewareOverrideHeaders + ',' + overwrittenHeaders.join(',')\n )\n }\n }\n\n return {\n response: finalResponse,\n waitUntil: getWaitUntilPromiseFromEvent(event) ?? Promise.resolve(),\n fetchMetrics: request.fetchMetrics,\n }\n}\n"],"names":["PageSignatureError","fromNodeOutgoingHttpHeaders","normalizeNextQueryParam","NextFetchEvent","getWaitUntilPromiseFromEvent","NextRequest","NextResponse","parseRelativeURL","getRelativeURL","NextURL","stripInternalSearchParams","normalizeRscURL","FLIGHT_HEADERS","NEXT_REWRITTEN_PATH_HEADER","NEXT_REWRITTEN_QUERY_HEADER","RSC_HEADER","ensureInstrumentationRegistered","createRequestStoreForAPI","workUnitAsyncStorage","createWorkStore","workAsyncStorage","NEXT_ROUTER_PREFETCH_HEADER","getTracer","MiddlewareSpan","CloseController","getEdgePreviewProps","getBuiltinRequestContext","getImplicitTags","NextRequestHint","constructor","params","input","init","sourcePage","page","request","respondWith","waitUntil","headersGetter","keys","headers","Array","from","get","key","undefined","propagator","fn","tracer","withPropagatedContext","testApisIntercepted","ensureTestApisIntercepted","process","env","NEXT_PRIVATE_TEST_PROXY","interceptTestApis","wrapRequestHandler","require","adapter","isEdgeRendering","globalThis","__BUILD_MANIFEST","url","requestURL","nextConfig","searchParams","value","getAll","normalizedKey","delete","val","append","buildId","requestHeaders","isNextDataRequest","has","isRSCRequest","pathname","flightHeaders","Map","header","toLowerCase","set","normalizeURL","__NEXT_NO_MIDDLEWARE_URL_NORMALIZE","URL","toString","body","method","signal","Object","defineProperty","enumerable","__incrementalCacheShared","IncrementalCache","__incrementalCache","appDir","fetchCache","minimalMode","NODE_ENV","fetchCacheKeyPrefix","__NEXT_FETCH_CACHE_KEY_PREFIX","dev","requestProtocol","getPrerenderManifest","version","routes","dynamicRoutes","notFoundRoutes","preview","outerWaitUntil","event","context","response","cookiesFromResponse","isMiddleware","bind","closeController","trace","execute","spanName","nextUrl","attributes","onUpdateCookies","cookies","previewProps","fallbackRouteParams","implicitTags","requestStore","workStore","renderOpts","cacheLifeProfiles","experimental","cacheLife","isRoutePPREnabled","dynamicIO","authInterrupts","supportsDynamicResponse","onClose","onAfterTaskError","requestEndedState","ended","isPrefetchRequest","previouslyRevalidatedTags","run","handler","setTimeout","dispatchClose","Response","TypeError","rewrite","destination","forceLocale","host","String","relativeDestination","isRelative","__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE","match","search","slice","redirect","redirectURL","finalResponse","next","middlewareOverrideHeaders","overwrittenHeaders","push","length","join","Promise","resolve","fetchMetrics"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,UAAS;AAC5C,SAASC,2BAA2B,EAAEC,uBAAuB,QAAQ,UAAS;AAC9E,SACEC,cAAc,EACdC,4BAA4B,QACvB,+BAA8B;AACrC,SAASC,WAAW,QAAQ,2BAA0B;AACtD,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SACEC,gBAAgB,EAChBC,cAAc,QACT,+CAA8C;AACrD,SAASC,OAAO,QAAQ,aAAY;AACpC,SAASC,yBAAyB,QAAQ,oBAAmB;AAC7D,SAASC,eAAe,QAAQ,0CAAyC;AACzE,SACEC,cAAc,EACdC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,UAAU,QACL,6CAA4C;AACnD,SAASC,+BAA+B,QAAQ,YAAW;AAC3D,SAASC,wBAAwB,QAAQ,iCAAgC;AACzE,SAASC,oBAAoB,QAAQ,iDAAgD;AACrF,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SAASC,gBAAgB,QAAQ,4CAA2C;AAC5E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;YACzDoG,mBAAmBC,IAAI,CAAC3H;QAC1B;QAEA,IAAI0H,mBAAmBE,MAAM,GAAG,GAAG;YACjCL,cAAc3H,OAAO,CAAC0C,GAAG,CACvB,iCACAmF,4BAA4B,MAAMC,mBAAmBG,IAAI,CAAC;QAE9D;IACF;IAEA,OAAO;QACLxD,UAAUkD;QACV9H,WAAWjC,6BAA6B2G,UAAU2D,QAAQC,OAAO;QACjEC,cAAczI,QAAQyI,YAAY;IACpC;AACF","ignoreList":[0]}
@@ -40,6 +40,7 @@ export async function getRuntimeContext(params) {
40
40
  distDir: params.distDir
41
41
  });
42
42
  if (params.incrementalCache) {
43
+ runtime.context.globalThis.__incrementalCacheShared = true;
43
44
  runtime.context.globalThis.__incrementalCache = params.incrementalCache;
44
45
  }
45
46
  if (params.serverComponentsHmrCache) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/server/web/sandbox/sandbox.ts"],"sourcesContent":["import type { NodejsRequestData, FetchEventResult, RequestData } from '../types'\nimport type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin'\nimport type { EdgeRuntime } from 'next/dist/compiled/edge-runtime'\nimport {\n getModuleContext,\n requestStore,\n edgeSandboxNextRequestContext,\n} from './context'\nimport { requestToBodyStream } from '../../body-streams'\nimport { NEXT_RSC_UNION_QUERY } from '../../../client/components/app-router-headers'\nimport type { ServerComponentsHmrCache } from '../../response-cache'\nimport {\n getBuiltinRequestContext,\n type BuiltinRequestContextValue,\n} from '../../after/builtin-request-context'\n\nexport const ErrorSource = Symbol('SandboxError')\n\nconst FORBIDDEN_HEADERS = [\n 'content-length',\n 'content-encoding',\n 'transfer-encoding',\n]\n\ninterface RunnerFnParams {\n name: string\n onError?: (err: unknown) => void\n onWarning?: (warn: Error) => void\n paths: string[]\n request: NodejsRequestData\n useCache: boolean\n edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'assets' | 'wasm' | 'env'>\n distDir: string\n incrementalCache?: any\n serverComponentsHmrCache?: ServerComponentsHmrCache\n}\n\ntype RunnerFn = (params: RunnerFnParams) => Promise<FetchEventResult>\n\n/**\n * Decorates the runner function making sure all errors it can produce are\n * tagged with `edge-server` so they can properly be rendered in dev.\n */\nfunction withTaggedErrors(fn: RunnerFn): RunnerFn {\n if (process.env.NODE_ENV === 'development') {\n const { getServerError } =\n require('../../../client/components/react-dev-overlay/server/middleware-webpack') as typeof import('../../../client/components/react-dev-overlay/server/middleware-webpack')\n\n return (params) =>\n fn(params)\n .then((result) => ({\n ...result,\n waitUntil: result?.waitUntil?.catch((error) => {\n // TODO: used COMPILER_NAMES.edgeServer instead. Verify that it does not increase the runtime size.\n throw getServerError(error, 'edge-server')\n }),\n }))\n .catch((error) => {\n // TODO: used COMPILER_NAMES.edgeServer instead\n throw getServerError(error, 'edge-server')\n })\n }\n\n return fn\n}\n\nexport async function getRuntimeContext(\n params: Omit<RunnerFnParams, 'request'>\n): Promise<EdgeRuntime<any>> {\n const { runtime, evaluateInContext } = await getModuleContext({\n moduleName: params.name,\n onWarning: params.onWarning ?? (() => {}),\n onError: params.onError ?? (() => {}),\n useCache: params.useCache !== false,\n edgeFunctionEntry: params.edgeFunctionEntry,\n distDir: params.distDir,\n })\n\n if (params.incrementalCache) {\n runtime.context.globalThis.__incrementalCache = params.incrementalCache\n }\n\n if (params.serverComponentsHmrCache) {\n runtime.context.globalThis.__serverComponentsHmrCache =\n params.serverComponentsHmrCache\n }\n\n for (const paramPath of params.paths) {\n evaluateInContext(paramPath)\n }\n return runtime\n}\n\nexport const run = withTaggedErrors(async function runWithTaggedErrors(params) {\n const runtime = await getRuntimeContext(params)\n\n const edgeFunction: (args: {\n request: RequestData\n }) => Promise<FetchEventResult> = (\n await runtime.context._ENTRIES[`middleware_${params.name}`]\n ).default\n\n const cloned = !['HEAD', 'GET'].includes(params.request.method)\n ? params.request.body?.cloneBodyStream()\n : undefined\n\n const KUint8Array = runtime.evaluate('Uint8Array')\n const urlInstance = new URL(params.request.url)\n urlInstance.searchParams.delete(NEXT_RSC_UNION_QUERY)\n\n params.request.url = urlInstance.toString()\n\n const headers = new Headers()\n for (const [key, value] of Object.entries(params.request.headers)) {\n headers.set(key, value?.toString() ?? '')\n }\n\n try {\n let result: FetchEventResult | undefined = undefined\n const builtinRequestCtx: BuiltinRequestContextValue = {\n ...getBuiltinRequestContext(),\n // FIXME(after):\n // arguably, this is an abuse of \"@next/request-context\" --\n // it'd make more sense to simply forward its existing value into the sandbox (in `createModuleContext`)\n // but here we're using it to just pass in `waitUntil` regardless if we were running in this context or not.\n waitUntil: params.request.waitUntil,\n }\n await edgeSandboxNextRequestContext.run(builtinRequestCtx, () =>\n requestStore.run({ headers }, async () => {\n result = await edgeFunction({\n request: {\n ...params.request,\n body:\n cloned &&\n requestToBodyStream(runtime.context, KUint8Array, cloned),\n },\n })\n for (const headerName of FORBIDDEN_HEADERS) {\n result.response.headers.delete(headerName)\n }\n })\n )\n\n if (!result) throw new Error('Edge function did not return a response')\n return result\n } finally {\n await params.request.body?.finalize()\n }\n})\n"],"names":["getModuleContext","requestStore","edgeSandboxNextRequestContext","requestToBodyStream","NEXT_RSC_UNION_QUERY","getBuiltinRequestContext","ErrorSource","Symbol","FORBIDDEN_HEADERS","withTaggedErrors","fn","process","env","NODE_ENV","getServerError","require","params","then","result","waitUntil","catch","error","getRuntimeContext","runtime","evaluateInContext","moduleName","name","onWarning","onError","useCache","edgeFunctionEntry","distDir","incrementalCache","context","globalThis","__incrementalCache","serverComponentsHmrCache","__serverComponentsHmrCache","paramPath","paths","run","runWithTaggedErrors","edgeFunction","_ENTRIES","default","cloned","includes","request","method","body","cloneBodyStream","undefined","KUint8Array","evaluate","urlInstance","URL","url","searchParams","delete","toString","headers","Headers","key","value","Object","entries","set","builtinRequestCtx","headerName","response","Error","finalize"],"mappings":"AAGA,SACEA,gBAAgB,EAChBC,YAAY,EACZC,6BAA6B,QACxB,YAAW;AAClB,SAASC,mBAAmB,QAAQ,qBAAoB;AACxD,SAASC,oBAAoB,QAAQ,gDA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J,UACA1C,oBAAoBoB,QAAQU,OAAO,EAAEmB,aAAaP;oBACtD;gBACF;gBACA,KAAK,MAAMuB,cAAc5D,kBAAmB;oBAC1CU,OAAOmD,QAAQ,CAACT,OAAO,CAACF,MAAM,CAACU;gBACjC;YACF;QAGF,IAAI,CAAClD,QAAQ,MAAM,qBAAoD,CAApD,IAAIoD,MAAM,4CAAV,qBAAA;mBAAA;wBAAA;0BAAA;QAAmD;QACtE,OAAOpD;IACT,SAAU;YACFF;QAAN,QAAMA,wBAAAA,OAAO+B,OAAO,CAACE,IAAI,qBAAnBjC,sBAAqBuD,QAAQ;IACrC;AACF,GAAE","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/server/web/sandbox/sandbox.ts"],"sourcesContent":["import type { NodejsRequestData, FetchEventResult, RequestData } from '../types'\nimport type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin'\nimport type { EdgeRuntime } from 'next/dist/compiled/edge-runtime'\nimport {\n getModuleContext,\n requestStore,\n edgeSandboxNextRequestContext,\n} from './context'\nimport { requestToBodyStream } from '../../body-streams'\nimport { NEXT_RSC_UNION_QUERY } from '../../../client/components/app-router-headers'\nimport type { ServerComponentsHmrCache } from '../../response-cache'\nimport {\n getBuiltinRequestContext,\n type BuiltinRequestContextValue,\n} from '../../after/builtin-request-context'\n\nexport const ErrorSource = Symbol('SandboxError')\n\nconst FORBIDDEN_HEADERS = [\n 'content-length',\n 'content-encoding',\n 'transfer-encoding',\n]\n\ninterface RunnerFnParams {\n name: string\n onError?: (err: unknown) => void\n onWarning?: (warn: Error) => void\n paths: string[]\n request: NodejsRequestData\n useCache: boolean\n edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'assets' | 'wasm' | 'env'>\n distDir: string\n incrementalCache?: any\n serverComponentsHmrCache?: ServerComponentsHmrCache\n}\n\ntype RunnerFn = (params: RunnerFnParams) => Promise<FetchEventResult>\n\n/**\n * Decorates the runner function making sure all errors it can produce are\n * tagged with `edge-server` so they can properly be rendered in dev.\n */\nfunction withTaggedErrors(fn: RunnerFn): RunnerFn {\n if (process.env.NODE_ENV === 'development') {\n const { getServerError } =\n require('../../../client/components/react-dev-overlay/server/middleware-webpack') as typeof import('../../../client/components/react-dev-overlay/server/middleware-webpack')\n\n return (params) =>\n fn(params)\n .then((result) => ({\n ...result,\n waitUntil: result?.waitUntil?.catch((error) => {\n // TODO: used COMPILER_NAMES.edgeServer instead. Verify that it does not increase the runtime size.\n throw getServerError(error, 'edge-server')\n }),\n }))\n .catch((error) => {\n // TODO: used COMPILER_NAMES.edgeServer instead\n throw getServerError(error, 'edge-server')\n })\n }\n\n return fn\n}\n\nexport async function getRuntimeContext(\n params: Omit<RunnerFnParams, 'request'>\n): Promise<EdgeRuntime<any>> {\n const { runtime, evaluateInContext } = await getModuleContext({\n moduleName: params.name,\n onWarning: params.onWarning ?? (() => {}),\n onError: params.onError ?? (() => {}),\n useCache: params.useCache !== false,\n edgeFunctionEntry: params.edgeFunctionEntry,\n distDir: params.distDir,\n })\n\n if (params.incrementalCache) {\n runtime.context.globalThis.__incrementalCacheShared = true\n runtime.context.globalThis.__incrementalCache = params.incrementalCache\n }\n\n if (params.serverComponentsHmrCache) {\n runtime.context.globalThis.__serverComponentsHmrCache =\n params.serverComponentsHmrCache\n }\n\n for (const paramPath of params.paths) {\n evaluateInContext(paramPath)\n }\n return runtime\n}\n\nexport const run = withTaggedErrors(async function runWithTaggedErrors(params) {\n const runtime = await getRuntimeContext(params)\n\n const edgeFunction: (args: {\n request: RequestData\n }) => Promise<FetchEventResult> = (\n await runtime.context._ENTRIES[`middleware_${params.name}`]\n ).default\n\n const cloned = !['HEAD', 'GET'].includes(params.request.method)\n ? params.request.body?.cloneBodyStream()\n : undefined\n\n const KUint8Array = runtime.evaluate('Uint8Array')\n const urlInstance = new URL(params.request.url)\n urlInstance.searchParams.delete(NEXT_RSC_UNION_QUERY)\n\n params.request.url = urlInstance.toString()\n\n const headers = new Headers()\n for (const [key, value] of Object.entries(params.request.headers)) {\n headers.set(key, value?.toString() ?? '')\n }\n\n try {\n let result: FetchEventResult | undefined = undefined\n const builtinRequestCtx: BuiltinRequestContextValue = {\n ...getBuiltinRequestContext(),\n // FIXME(after):\n // arguably, this is an abuse of \"@next/request-context\" --\n // it'd make more sense to simply forward its existing value into the sandbox (in `createModuleContext`)\n // but here we're using it to just pass in `waitUntil` regardless if we were running in this context or not.\n waitUntil: params.request.waitUntil,\n }\n await edgeSandboxNextRequestContext.run(builtinRequestCtx, () =>\n requestStore.run({ headers }, async () => {\n result = await edgeFunction({\n request: {\n ...params.request,\n body:\n cloned &&\n requestToBodyStream(runtime.context, KUint8Array, cloned),\n },\n })\n for (const headerName of FORBIDDEN_HEADERS) {\n result.response.headers.delete(headerName)\n }\n })\n )\n\n if (!result) throw new Error('Edge function did not return a response')\n return result\n } finally {\n await params.request.body?.finalize()\n }\n})\n"],"names":["getModuleContext","requestStore","edgeSandboxNextRequestContext","requestToBodyStream","NEXT_RSC_UNION_QUERY","getBuiltinRequestContext","ErrorSource","Symbol","FORBIDDEN_HEADERS","withTaggedErrors","fn","process","env","NODE_ENV","getServerError","require","params","then","result","waitUntil","catch","error","getRuntimeContext","runtime","evaluateInContext","moduleName","name","onWarning","onError","useCache","edgeFunctionEntry","distDir","incrementalCache","context","globalThis","__incrementalCacheShared","__incrementalCache","serverComponentsHmrCache","__serverComponentsHmrCache","paramPath","paths","run","runWithTaggedErrors","edgeFunction","_ENTRIES","default","cloned","includes","request","method","body","cloneBodyStream","undefined","KUint8Array","evaluate","urlInstance","URL","url","searchParams","delete","toString","headers","Headers","key","value","Object","entries","set","builtinRequestCtx","headerName","response","Error","finalize"],"mappings":"AAGA,SACEA,gBAAgB,EAChBC,YAAY,EACZC,6BAA6B,QACxB,YAAW;AAClB,SAASC,mBAAmB,QAAQ,qBAAoB;AACxD,SAASC,oBAAoB,QAAQ,gDAA+C;AAEpF,SACEC,wBAAwB,QAEnB,sCAAqC;AAE5C,OAAO,MAAMC,cAAcC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BAAoBoB,QAAQU,OAAO,EAAEoB,aAAaP;oBACtD;gBACF;gBACA,KAAK,MAAMuB,cAAc7D,kBAAmB;oBAC1CU,OAAOoD,QAAQ,CAACT,OAAO,CAACF,MAAM,CAACU;gBACjC;YACF;QAGF,IAAI,CAACnD,QAAQ,MAAM,qBAAoD,CAApD,IAAIqD,MAAM,4CAAV,qBAAA;mBAAA;wBAAA;0BAAA;QAAmD;QACtE,OAAOrD;IACT,SAAU;YACFF;QAAN,QAAMA,wBAAAA,OAAOgC,OAAO,CAACE,IAAI,qBAAnBlC,sBAAqBwD,QAAQ;IACrC;AACF,GAAE","ignoreList":[0]}
@@ -1,6 +1,6 @@
1
1
  export function isStableBuild() {
2
2
  var _process_env___NEXT_VERSION;
3
- return !((_process_env___NEXT_VERSION = "15.4.0-canary.42") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
3
+ return !((_process_env___NEXT_VERSION = "15.4.0-canary.43") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
4
4
  }
5
5
  export class CanaryOnlyError extends Error {
6
6
  constructor(arg){
@@ -1422,7 +1422,7 @@ class Server {
1422
1422
  protocol = parsedFullUrl.protocol;
1423
1423
  } catch {}
1424
1424
  // use existing incrementalCache instance if available
1425
- const incrementalCache = globalThis.__incrementalCache || await this.getIncrementalCache({
1425
+ const incrementalCache = process.env.NEXT_RUNTIME === 'edge' && globalThis.__incrementalCache ? globalThis.__incrementalCache : await this.getIncrementalCache({
1426
1426
  requestHeaders: Object.assign({}, req.headers),
1427
1427
  requestProtocol: protocol.substring(0, protocol.length - 1)
1428
1428
  });