next 15.2.0-canary.47 → 15.2.0-canary.48

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.

Potentially problematic release.


This version of next might be problematic. Click here for more details.

Files changed (65) 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/webpack-config.js +2 -2
  5. package/dist/client/app-bootstrap.js +1 -1
  6. package/dist/client/app-dir/link.d.ts +108 -28
  7. package/dist/client/app-dir/link.js +6 -4
  8. package/dist/client/app-dir/link.js.map +1 -1
  9. package/dist/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js +3 -2
  10. package/dist/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js.map +1 -1
  11. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js +8 -6
  12. package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js.map +1 -1
  13. package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js +2 -3
  14. package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js.map +1 -1
  15. package/dist/client/components/react-dev-overlay/server/middleware-turbopack.js +39 -13
  16. package/dist/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
  17. package/dist/client/components/react-dev-overlay/server/middleware-webpack.js +13 -3
  18. package/dist/client/components/react-dev-overlay/server/middleware-webpack.js.map +1 -1
  19. package/dist/client/index.js +1 -1
  20. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +2 -2
  21. package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
  22. package/dist/compiled/next-server/app-page.runtime.dev.js +2 -2
  23. package/dist/compiled/next-server/app-page.runtime.dev.js.map +1 -1
  24. package/dist/compiled/next-server/server.runtime.prod.js +6 -6
  25. package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
  26. package/dist/esm/build/index.js +2 -2
  27. package/dist/esm/build/swc/index.js +1 -1
  28. package/dist/esm/build/webpack-config.js +2 -2
  29. package/dist/esm/client/app-bootstrap.js +1 -1
  30. package/dist/esm/client/app-dir/link.js +6 -4
  31. package/dist/esm/client/app-dir/link.js.map +1 -1
  32. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js +3 -2
  33. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js.map +1 -1
  34. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js +8 -6
  35. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js.map +1 -1
  36. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js +2 -3
  37. package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js.map +1 -1
  38. package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js +39 -13
  39. package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
  40. package/dist/esm/client/components/react-dev-overlay/server/middleware-webpack.js +13 -3
  41. package/dist/esm/client/components/react-dev-overlay/server/middleware-webpack.js.map +1 -1
  42. package/dist/esm/client/index.js +1 -1
  43. package/dist/esm/lib/metadata/types/metadata-interface.js +13 -1
  44. package/dist/esm/lib/metadata/types/metadata-interface.js.map +1 -1
  45. package/dist/esm/server/config.js +1 -1
  46. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  47. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  48. package/dist/esm/server/lib/app-info-log.js +1 -1
  49. package/dist/esm/server/lib/start-server.js +1 -1
  50. package/dist/esm/server/patch-error-inspect.js +42 -15
  51. package/dist/esm/server/patch-error-inspect.js.map +1 -1
  52. package/dist/lib/metadata/types/metadata-interface.d.ts +252 -179
  53. package/dist/lib/metadata/types/metadata-interface.js +13 -1
  54. package/dist/lib/metadata/types/metadata-interface.js.map +1 -1
  55. package/dist/server/config.js +1 -1
  56. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  57. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  58. package/dist/server/lib/app-info-log.js +1 -1
  59. package/dist/server/lib/start-server.js +1 -1
  60. package/dist/server/patch-error-inspect.js +42 -15
  61. package/dist/server/patch-error-inspect.js.map +1 -1
  62. package/dist/telemetry/anonymous-meta.js +1 -1
  63. package/dist/telemetry/events/session-stopped.js +2 -2
  64. package/dist/telemetry/events/version.js +2 -2
  65. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/patch-error-inspect.ts"],"sourcesContent":["import {\n findSourceMap as nativeFindSourceMap,\n type SourceMapPayload,\n} from 'module'\nimport * as path from 'path'\nimport * as url from 'url'\nimport type * as util from 'util'\nimport { SourceMapConsumer as SyncSourceMapConsumer } from 'next/dist/compiled/source-map'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { parseStack } from '../client/components/react-dev-overlay/server/middleware-webpack'\nimport { getOriginalCodeFrame } from '../client/components/react-dev-overlay/server/shared'\nimport { workUnitAsyncStorage } from './app-render/work-unit-async-storage.external'\nimport { dim } from '../lib/picocolors'\n\ntype FindSourceMapPayload = (\n sourceURL: string\n) => ModernSourceMapPayload | undefined\n// Find a source map using the bundler's API.\n// This is only a fallback for when Node.js fails to due to bugs e.g. https://github.com/nodejs/node/issues/52102\n// TODO: Remove once all supported Node.js versions are fixed.\n// TODO(veil): Set from Webpack as well\nlet bundlerFindSourceMapPayload: FindSourceMapPayload = () => undefined\n\nexport function setBundlerFindSourceMapImplementation(\n findSourceMapImplementation: FindSourceMapPayload\n): void {\n bundlerFindSourceMapPayload = findSourceMapImplementation\n}\n\n/**\n * https://tc39.es/source-map/#index-map\n */\ninterface IndexSourceMapSection {\n offset: {\n line: number\n column: number\n }\n map: ModernRawSourceMap\n}\n\n// TODO(veil): Upstream types\ninterface IndexSourceMap {\n version: number\n file: string\n sections: IndexSourceMapSection[]\n}\n\ninterface ModernRawSourceMap extends SourceMapPayload {\n ignoreList?: number[]\n}\n\nexport type ModernSourceMapPayload = ModernRawSourceMap | IndexSourceMap\n\ninterface IgnoreableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceMapCache = Map<\n string,\n { map: SyncSourceMapConsumer; payload: ModernSourceMapPayload }\n>\n\nfunction frameToString(frame: StackFrame): string {\n let sourceLocation = frame.lineNumber !== null ? `:${frame.lineNumber}` : ''\n if (frame.column !== null && sourceLocation !== '') {\n sourceLocation += `:${frame.column}`\n }\n\n let fileLocation: string | null\n if (\n frame.file !== null &&\n frame.file.startsWith('file://') &&\n URL.canParse(frame.file)\n ) {\n // If not relative to CWD, the path is ambiguous to IDEs and clicking will prompt to select the file first.\n // In a multi-app repo, this leads to potentially larger file names but will make clicking snappy.\n // There's no tradeoff for the cases where `dir` in `next dev [dir]` is omitted\n // since relative to cwd is both the shortest and snappiest.\n fileLocation = path.relative(process.cwd(), url.fileURLToPath(frame.file))\n } else if (frame.file !== null && frame.file.startsWith('/')) {\n fileLocation = path.relative(process.cwd(), frame.file)\n } else {\n fileLocation = frame.file\n }\n\n return frame.methodName\n ? ` at ${frame.methodName} (${fileLocation}${sourceLocation})`\n : ` at ${fileLocation}${sourceLocation}`\n}\n\nfunction computeErrorName(error: Error): string {\n // TODO: Node.js seems to use a different algorithm\n // class ReadonlyRequestCookiesError extends Error {}` would read `ReadonlyRequestCookiesError: [...]`\n // in the stack i.e. seems like under certain conditions it favors the constructor name.\n return error.name || 'Error'\n}\n\nfunction prepareUnsourcemappedStackTrace(\n error: Error,\n structuredStackTrace: any[]\n): string {\n const name = computeErrorName(error)\n const message = error.message || ''\n let stack = name + ': ' + message\n for (let i = 0; i < structuredStackTrace.length; i++) {\n stack += '\\n at ' + structuredStackTrace[i].toString()\n }\n return stack\n}\n\nfunction shouldIgnoreListGeneratedFrame(file: string): boolean {\n return file.startsWith('node:') || file.includes('node_modules')\n}\n\nfunction shouldIgnoreListOriginalFrame(file: string): boolean {\n return file.includes('node_modules')\n}\n\n/**\n * Finds the sourcemap payload applicable to a given frame.\n * Equal to the input unless an Index Source Map is used.\n */\nfunction findApplicableSourceMapPayload(\n frame: StackFrame,\n payload: ModernSourceMapPayload\n): ModernRawSourceMap | undefined {\n if ('sections' in payload) {\n const frameLine = frame.lineNumber ?? 0\n const frameColumn = frame.column ?? 0\n // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object\n // Therefore the last section that has an offset less than or equal to the frame is the applicable one.\n // TODO(veil): Binary search\n let section: IndexSourceMapSection | undefined = payload.sections[0]\n for (\n let i = 0;\n i < payload.sections.length &&\n payload.sections[i].offset.line <= frameLine &&\n payload.sections[i].offset.column <= frameColumn;\n i++\n ) {\n section = payload.sections[i]\n }\n\n return section === undefined ? undefined : section.map\n } else {\n return payload\n }\n}\n\ninterface SourcemappableStackFrame extends StackFrame {\n file: NonNullable<StackFrame['file']>\n}\n\n/**\n * @param frame\n * @param sourceMapCache\n * @returns The original frame if not sourcemapped.\n */\nfunction getSourcemappedFrameIfPossible(\n frame: SourcemappableStackFrame,\n sourceMapCache: SourceMapCache,\n inspectOptions: util.InspectOptions\n): {\n stack: IgnoreableStackFrame\n // DEV only\n code: string | null\n} {\n const sourceMapCacheEntry = sourceMapCache.get(frame.file)\n let sourceMapConsumer: SyncSourceMapConsumer\n let sourceMapPayload: ModernSourceMapPayload\n if (sourceMapCacheEntry === undefined) {\n let sourceURL = frame.file\n // e.g. \"/APP/.next/server/chunks/ssr/[root of the server]__2934a0._.js\"\n // will be keyed by Node.js as \"file:///APP/.next/server/chunks/ssr/[root%20of%20the%20server]__2934a0._.js\".\n // This is likely caused by `callsite.toString()` in `Error.prepareStackTrace converting file URLs to paths.\n if (sourceURL.startsWith('/')) {\n sourceURL = url.pathToFileURL(frame.file).toString()\n }\n const maybeSourceMapPayload =\n nativeFindSourceMap(sourceURL)?.payload ??\n bundlerFindSourceMapPayload(sourceURL)\n if (maybeSourceMapPayload === undefined) {\n return {\n stack: {\n arguments: frame.arguments,\n column: frame.column,\n file: frame.file,\n lineNumber: frame.lineNumber,\n methodName: frame.methodName,\n ignored: shouldIgnoreListGeneratedFrame(frame.file),\n },\n code: null,\n }\n }\n sourceMapPayload = maybeSourceMapPayload\n sourceMapConsumer = new SyncSourceMapConsumer(\n // @ts-expect-error -- Module.SourceMap['version'] is number but SyncSourceMapConsumer wants a string\n sourceMapPayload\n )\n sourceMapCache.set(frame.file, {\n map: sourceMapConsumer,\n payload: sourceMapPayload,\n })\n } else {\n sourceMapConsumer = sourceMapCacheEntry.map\n sourceMapPayload = sourceMapCacheEntry.payload\n }\n\n const sourcePosition = sourceMapConsumer.originalPositionFor({\n column: frame.column ?? 0,\n line: frame.lineNumber ?? 1,\n })\n\n if (sourcePosition.source === null) {\n return {\n stack: {\n arguments: frame.arguments,\n column: frame.column,\n file: frame.file,\n lineNumber: frame.lineNumber,\n methodName: frame.methodName,\n ignored: shouldIgnoreListGeneratedFrame(frame.file),\n },\n code: null,\n }\n }\n\n const sourceContent: string | null =\n sourceMapConsumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame,\n sourceMapPayload\n )\n // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.\n let ignored = false\n if (applicableSourceMap === undefined) {\n console.error('No applicable source map found in sections for frame', frame)\n } else if (shouldIgnoreListOriginalFrame(sourcePosition.source)) {\n // Externals may be libraries that don't ship ignoreLists.\n // This is really taking control away from libraries.\n // They should still ship `ignoreList` so that attached debuggers ignore-list their frames.\n // TODO: Maybe only ignore library sourcemaps if `ignoreList` is absent?\n // Though keep in mind that Turbopack omits empty `ignoreList`.\n // So if we establish this convention, we should communicate it to the ecosystem.\n ignored = true\n } else {\n // TODO: O(n^2). Consider moving `ignoreList` into a Set\n const sourceIndex = applicableSourceMap.sources.indexOf(\n sourcePosition.source\n )\n ignored = applicableSourceMap.ignoreList?.includes(sourceIndex) ?? false\n }\n\n const originalFrame: IgnoreableStackFrame = {\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n methodName: frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n column: sourcePosition.column,\n file: sourcePosition.source,\n lineNumber: sourcePosition.line,\n // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?\n arguments: [],\n ignored,\n }\n\n const codeFrame =\n process.env.NODE_ENV !== 'production'\n ? getOriginalCodeFrame(\n originalFrame,\n sourceContent,\n inspectOptions.colors\n )\n : null\n\n return {\n stack: originalFrame,\n code: codeFrame,\n }\n}\n\nfunction parseAndSourceMap(\n error: Error,\n inspectOptions: util.InspectOptions\n): string {\n // TODO(veil): Expose as CLI arg or config option. Useful for local debugging.\n const showIgnoreListed = false\n // We overwrote Error.prepareStackTrace earlier so error.stack is not sourcemapped.\n let unparsedStack = String(error.stack)\n // We could just read it from `error.stack`.\n // This works around cases where a 3rd party `Error.prepareStackTrace` implementation\n // doesn't implement the name computation correctly.\n const errorName = computeErrorName(error)\n\n let idx = unparsedStack.indexOf('react-stack-bottom-frame')\n if (idx !== -1) {\n idx = unparsedStack.lastIndexOf('\\n', idx)\n }\n if (idx !== -1 && !showIgnoreListed) {\n // Cut off everything after the bottom frame since it'll be React internals.\n unparsedStack = unparsedStack.slice(0, idx)\n }\n\n const unsourcemappedStack = parseStack(unparsedStack)\n const sourceMapCache: SourceMapCache = new Map()\n\n let sourceMappedStack = ''\n let sourceFrameDEV: null | string = null\n for (const frame of unsourcemappedStack) {\n if (frame.file === null) {\n sourceMappedStack += '\\n' + frameToString(frame)\n } else {\n const sourcemappedFrame = getSourcemappedFrameIfPossible(\n // We narrowed this earlier by bailing if `frame.file` is null.\n frame as SourcemappableStackFrame,\n sourceMapCache,\n inspectOptions\n )\n\n if (\n process.env.NODE_ENV !== 'production' &&\n sourcemappedFrame.code !== null &&\n sourceFrameDEV === null &&\n // TODO: Is this the right choice?\n !sourcemappedFrame.stack.ignored\n ) {\n sourceFrameDEV = sourcemappedFrame.code\n }\n if (!sourcemappedFrame.stack.ignored) {\n // TODO: Consider what happens if every frame is ignore listed.\n sourceMappedStack += '\\n' + frameToString(sourcemappedFrame.stack)\n } else if (showIgnoreListed && !inspectOptions.colors) {\n sourceMappedStack += '\\n' + frameToString(sourcemappedFrame.stack)\n } else if (showIgnoreListed) {\n sourceMappedStack += '\\n' + dim(frameToString(sourcemappedFrame.stack))\n }\n }\n }\n\n return (\n errorName +\n ': ' +\n error.message +\n sourceMappedStack +\n (sourceFrameDEV !== null ? '\\n' + sourceFrameDEV : '')\n )\n}\n\nfunction sourceMapError(\n this: void,\n error: Error,\n inspectOptions: util.InspectOptions\n): Error {\n // Create a new Error object with the source mapping applied and then use native\n // Node.js formatting on the result.\n const newError =\n error.cause !== undefined\n ? // Setting an undefined `cause` would print `[cause]: undefined`\n new Error(error.message, { cause: error.cause })\n : new Error(error.message)\n\n // TODO: Ensure `class MyError extends Error {}` prints `MyError` as the name\n newError.stack = parseAndSourceMap(error, inspectOptions)\n\n for (const key in error) {\n if (!Object.prototype.hasOwnProperty.call(newError, key)) {\n // @ts-expect-error -- We're copying all enumerable properties.\n // So they definitely exist on `this` and obviously have no type on `newError` (yet)\n newError[key] = error[key]\n }\n }\n\n return newError\n}\n\nexport function patchErrorInspectNodeJS(\n errorConstructor: ErrorConstructor\n): void {\n const inspectSymbol = Symbol.for('nodejs.util.inspect.custom')\n\n errorConstructor.prepareStackTrace = prepareUnsourcemappedStackTrace\n\n // @ts-expect-error -- TODO upstream types\n // eslint-disable-next-line no-extend-native -- We're not extending but overriding.\n errorConstructor.prototype[inspectSymbol] = function (\n depth: number,\n inspectOptions: util.InspectOptions,\n inspect: typeof util.inspect\n ): string {\n // avoid false-positive dynamic i/o warnings e.g. due to usage of `Math.random` in `source-map`.\n return workUnitAsyncStorage.exit(() => {\n const newError = sourceMapError(this, inspectOptions)\n\n const originalCustomInspect = (newError as any)[inspectSymbol]\n // Prevent infinite recursion.\n // { customInspect: false } would result in `error.cause` not using our inspect.\n Object.defineProperty(newError, inspectSymbol, {\n value: undefined,\n enumerable: false,\n writable: true,\n })\n try {\n return inspect(newError, {\n ...inspectOptions,\n depth:\n (inspectOptions.depth ??\n // Default in Node.js\n 2) - depth,\n })\n } finally {\n ;(newError as any)[inspectSymbol] = originalCustomInspect\n }\n })\n }\n}\n\nexport function patchErrorInspectEdgeLite(\n errorConstructor: ErrorConstructor\n): void {\n const inspectSymbol = Symbol.for('edge-runtime.inspect.custom')\n\n errorConstructor.prepareStackTrace = prepareUnsourcemappedStackTrace\n\n // @ts-expect-error -- TODO upstream types\n // eslint-disable-next-line no-extend-native -- We're not extending but overriding.\n errorConstructor.prototype[inspectSymbol] = function ({\n format,\n }: {\n format: (...args: unknown[]) => string\n }): string {\n // avoid false-positive dynamic i/o warnings e.g. due to usage of `Math.random` in `source-map`.\n return workUnitAsyncStorage.exit(() => {\n const newError = sourceMapError(this, {})\n\n const originalCustomInspect = (newError as any)[inspectSymbol]\n // Prevent infinite recursion.\n Object.defineProperty(newError, inspectSymbol, {\n value: undefined,\n enumerable: false,\n writable: true,\n })\n try {\n return format(newError)\n } finally {\n ;(newError as any)[inspectSymbol] = originalCustomInspect\n }\n })\n }\n}\n"],"names":["findSourceMap","nativeFindSourceMap","path","url","SourceMapConsumer","SyncSourceMapConsumer","parseStack","getOriginalCodeFrame","workUnitAsyncStorage","dim","bundlerFindSourceMapPayload","undefined","setBundlerFindSourceMapImplementation","findSourceMapImplementation","frameToString","frame","sourceLocation","lineNumber","column","fileLocation","file","startsWith","URL","canParse","relative","process","cwd","fileURLToPath","methodName","computeErrorName","error","name","prepareUnsourcemappedStackTrace","structuredStackTrace","message","stack","i","length","toString","shouldIgnoreListGeneratedFrame","includes","shouldIgnoreListOriginalFrame","findApplicableSourceMapPayload","payload","frameLine","frameColumn","section","sections","offset","line","map","getSourcemappedFrameIfPossible","sourceMapCache","inspectOptions","sourceMapCacheEntry","get","sourceMapConsumer","sourceMapPayload","sourceURL","pathToFileURL","maybeSourceMapPayload","arguments","ignored","code","set","sourcePosition","originalPositionFor","source","sourceContent","sourceContentFor","applicableSourceMap","console","sourceIndex","sources","indexOf","ignoreList","originalFrame","replace","codeFrame","env","NODE_ENV","colors","parseAndSourceMap","showIgnoreListed","unparsedStack","String","errorName","idx","lastIndexOf","slice","unsourcemappedStack","Map","sourceMappedStack","sourceFrameDEV","sourcemappedFrame","sourceMapError","newError","cause","Error","key","Object","prototype","hasOwnProperty","call","patchErrorInspectNodeJS","errorConstructor","inspectSymbol","Symbol","for","prepareStackTrace","depth","inspect","exit","originalCustomInspect","defineProperty","value","enumerable","writable","patchErrorInspectEdgeLite","format"],"mappings":"AAAA,SACEA,iBAAiBC,mBAAmB,QAE/B,SAAQ;AACf,YAAYC,UAAU,OAAM;AAC5B,YAAYC,SAAS,MAAK;AAE1B,SAASC,qBAAqBC,qBAAqB,QAAQ,gCAA+B;AAE1F,SAASC,UAAU,QAAQ,mEAAkE;AAC7F,SAASC,oBAAoB,QAAQ,uDAAsD;AAC3F,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,GAAG,QAAQ,oBAAmB;AAKvC,6CAA6C;AAC7C,iHAAiH;AACjH,8DAA8D;AAC9D,uCAAuC;AACvC,IAAIC,8BAAoD,IAAMC;AAE9D,OAAO,SAASC,sCACdC,2BAAiD;IAEjDH,8BAA8BG;AAChC;AAmCA,SAASC,cAAcC,KAAiB;IACtC,IAAIC,iBAAiBD,MAAME,UAAU,KAAK,OAAO,CAAC,CAAC,EAAEF,MAAME,UAAU,EAAE,GAAG;IAC1E,IAAIF,MAAMG,MAAM,KAAK,QAAQF,mBAAmB,IAAI;QAClDA,kBAAkB,CAAC,CAAC,EAAED,MAAMG,MAAM,EAAE;IACtC;IAE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QAAgB,CAACU,cAAc;YAC9D,8BAA8B;YAC9BN,OAAOc,cAAc,CAAClB,UAAUU,eAAe;gBAC7CS,OAAOxG;gBACPyG,YAAY;gBACZC,UAAU;YACZ;YACA,IAAI;gBACF,OAAOE,OAAOvB;YAChB,SAAU;;gBACNA,QAAgB,CAACU,cAAc,GAAGO;YACtC;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/server/patch-error-inspect.ts"],"sourcesContent":["import {\n findSourceMap as nativeFindSourceMap,\n type SourceMapPayload,\n} from 'module'\nimport * as path from 'path'\nimport * as url from 'url'\nimport type * as util from 'util'\nimport { SourceMapConsumer as SyncSourceMapConsumer } from 'next/dist/compiled/source-map'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport { parseStack } from '../client/components/react-dev-overlay/server/middleware-webpack'\nimport { getOriginalCodeFrame } from '../client/components/react-dev-overlay/server/shared'\nimport { workUnitAsyncStorage } from './app-render/work-unit-async-storage.external'\nimport { dim } from '../lib/picocolors'\n\ntype FindSourceMapPayload = (\n sourceURL: string\n) => ModernSourceMapPayload | undefined\n// Find a source map using the bundler's API.\n// This is only a fallback for when Node.js fails to due to bugs e.g. https://github.com/nodejs/node/issues/52102\n// TODO: Remove once all supported Node.js versions are fixed.\n// TODO(veil): Set from Webpack as well\nlet bundlerFindSourceMapPayload: FindSourceMapPayload = () => undefined\n\nexport function setBundlerFindSourceMapImplementation(\n findSourceMapImplementation: FindSourceMapPayload\n): void {\n bundlerFindSourceMapPayload = findSourceMapImplementation\n}\n\n/**\n * https://tc39.es/source-map/#index-map\n */\ninterface IndexSourceMapSection {\n offset: {\n line: number\n column: number\n }\n map: ModernRawSourceMap\n}\n\n// TODO(veil): Upstream types\ninterface IndexSourceMap {\n version: number\n file: string\n sections: IndexSourceMapSection[]\n}\n\ninterface ModernRawSourceMap extends SourceMapPayload {\n ignoreList?: number[]\n}\n\nexport type ModernSourceMapPayload = ModernRawSourceMap | IndexSourceMap\n\ninterface IgnoreableStackFrame extends StackFrame {\n ignored: boolean\n}\n\ntype SourceMapCache = Map<\n string,\n { map: SyncSourceMapConsumer; payload: ModernSourceMapPayload }\n>\n\nfunction frameToString(frame: StackFrame): string {\n let sourceLocation = frame.lineNumber !== null ? `:${frame.lineNumber}` : ''\n if (frame.column !== null && sourceLocation !== '') {\n sourceLocation += `:${frame.column}`\n }\n\n let fileLocation: string | null\n if (\n frame.file !== null &&\n frame.file.startsWith('file://') &&\n URL.canParse(frame.file)\n ) {\n // If not relative to CWD, the path is ambiguous to IDEs and clicking will prompt to select the file first.\n // In a multi-app repo, this leads to potentially larger file names but will make clicking snappy.\n // There's no tradeoff for the cases where `dir` in `next dev [dir]` is omitted\n // since relative to cwd is both the shortest and snappiest.\n fileLocation = path.relative(process.cwd(), url.fileURLToPath(frame.file))\n } else if (frame.file !== null && frame.file.startsWith('/')) {\n fileLocation = path.relative(process.cwd(), frame.file)\n } else {\n fileLocation = frame.file\n }\n\n return frame.methodName\n ? ` at ${frame.methodName} (${fileLocation}${sourceLocation})`\n : ` at ${fileLocation}${sourceLocation}`\n}\n\nfunction computeErrorName(error: Error): string {\n // TODO: Node.js seems to use a different algorithm\n // class ReadonlyRequestCookiesError extends Error {}` would read `ReadonlyRequestCookiesError: [...]`\n // in the stack i.e. seems like under certain conditions it favors the constructor name.\n return error.name || 'Error'\n}\n\nfunction prepareUnsourcemappedStackTrace(\n error: Error,\n structuredStackTrace: any[]\n): string {\n const name = computeErrorName(error)\n const message = error.message || ''\n let stack = name + ': ' + message\n for (let i = 0; i < structuredStackTrace.length; i++) {\n stack += '\\n at ' + structuredStackTrace[i].toString()\n }\n return stack\n}\n\nfunction shouldIgnoreListGeneratedFrame(file: string): boolean {\n return file.startsWith('node:') || file.includes('node_modules')\n}\n\nfunction shouldIgnoreListOriginalFrame(file: string): boolean {\n return file.includes('node_modules')\n}\n\n/**\n * Finds the sourcemap payload applicable to a given frame.\n * Equal to the input unless an Index Source Map is used.\n */\nfunction findApplicableSourceMapPayload(\n frame: StackFrame,\n payload: ModernSourceMapPayload\n): ModernRawSourceMap | undefined {\n if ('sections' in payload) {\n const frameLine = frame.lineNumber ?? 0\n const frameColumn = frame.column ?? 0\n // Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object\n // Therefore the last section that has an offset less than or equal to the frame is the applicable one.\n // TODO(veil): Binary search\n let section: IndexSourceMapSection | undefined = payload.sections[0]\n for (\n let i = 0;\n i < payload.sections.length &&\n payload.sections[i].offset.line <= frameLine &&\n payload.sections[i].offset.column <= frameColumn;\n i++\n ) {\n section = payload.sections[i]\n }\n\n return section === undefined ? undefined : section.map\n } else {\n return payload\n }\n}\n\ninterface SourcemappableStackFrame extends StackFrame {\n file: NonNullable<StackFrame['file']>\n}\n\ninterface SourceMappedFrame {\n stack: IgnoreableStackFrame\n // DEV only\n code: string | null\n}\n\nfunction createUnsourcemappedFrame(\n frame: SourcemappableStackFrame\n): SourceMappedFrame {\n return {\n stack: {\n arguments: frame.arguments,\n column: frame.column,\n file: frame.file,\n lineNumber: frame.lineNumber,\n methodName: frame.methodName,\n ignored: shouldIgnoreListGeneratedFrame(frame.file),\n },\n code: null,\n }\n}\n\n/**\n * @param frame\n * @param sourceMapCache\n * @returns The original frame if not sourcemapped.\n */\nfunction getSourcemappedFrameIfPossible(\n frame: SourcemappableStackFrame,\n sourceMapCache: SourceMapCache,\n inspectOptions: util.InspectOptions\n): {\n stack: IgnoreableStackFrame\n // DEV only\n code: string | null\n} {\n const sourceMapCacheEntry = sourceMapCache.get(frame.file)\n let sourceMapConsumer: SyncSourceMapConsumer\n let sourceMapPayload: ModernSourceMapPayload\n if (sourceMapCacheEntry === undefined) {\n let sourceURL = frame.file\n // e.g. \"/APP/.next/server/chunks/ssr/[root of the server]__2934a0._.js\"\n // will be keyed by Node.js as \"file:///APP/.next/server/chunks/ssr/[root%20of%20the%20server]__2934a0._.js\".\n // This is likely caused by `callsite.toString()` in `Error.prepareStackTrace converting file URLs to paths.\n if (sourceURL.startsWith('/')) {\n sourceURL = url.pathToFileURL(frame.file).toString()\n }\n let maybeSourceMapPayload: ModernSourceMapPayload | undefined\n try {\n const sourceMap = nativeFindSourceMap(sourceURL)\n maybeSourceMapPayload = sourceMap?.payload\n } catch (cause) {\n // We should not log an actual error instance here because that will re-enter\n // this codepath during error inspection and could lead to infinite recursion.\n console.error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`\n )\n // Don't even fall back to the bundler because it might be not as strict\n // with regards to parsing and then we fail later once we consume the\n // source map payload.\n // This essentially avoids a redundant error where we fail here and then\n // later on consumption because the bundler just handed back an invalid\n // source map.\n return createUnsourcemappedFrame(frame)\n }\n if (maybeSourceMapPayload === undefined) {\n maybeSourceMapPayload = bundlerFindSourceMapPayload(sourceURL)\n }\n\n if (maybeSourceMapPayload === undefined) {\n return createUnsourcemappedFrame(frame)\n }\n sourceMapPayload = maybeSourceMapPayload\n try {\n sourceMapConsumer = new SyncSourceMapConsumer(\n // @ts-expect-error -- Module.SourceMap['version'] is number but SyncSourceMapConsumer wants a string\n sourceMapPayload\n )\n } catch (cause) {\n // We should not log an actual error instance here because that will re-enter\n // this codepath during error inspection and could lead to infinite recursion.\n console.error(\n `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code. Cause: ${cause}`\n )\n return createUnsourcemappedFrame(frame)\n }\n sourceMapCache.set(frame.file, {\n map: sourceMapConsumer,\n payload: sourceMapPayload,\n })\n } else {\n sourceMapConsumer = sourceMapCacheEntry.map\n sourceMapPayload = sourceMapCacheEntry.payload\n }\n\n const sourcePosition = sourceMapConsumer.originalPositionFor({\n column: frame.column ?? 0,\n line: frame.lineNumber ?? 1,\n })\n\n if (sourcePosition.source === null) {\n return {\n stack: {\n arguments: frame.arguments,\n column: frame.column,\n file: frame.file,\n lineNumber: frame.lineNumber,\n methodName: frame.methodName,\n ignored: shouldIgnoreListGeneratedFrame(frame.file),\n },\n code: null,\n }\n }\n\n const sourceContent: string | null =\n sourceMapConsumer.sourceContentFor(\n sourcePosition.source,\n /* returnNullOnMissing */ true\n ) ?? null\n\n const applicableSourceMap = findApplicableSourceMapPayload(\n frame,\n sourceMapPayload\n )\n // TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.\n let ignored = false\n if (applicableSourceMap === undefined) {\n console.error('No applicable source map found in sections for frame', frame)\n } else if (shouldIgnoreListOriginalFrame(sourcePosition.source)) {\n // Externals may be libraries that don't ship ignoreLists.\n // This is really taking control away from libraries.\n // They should still ship `ignoreList` so that attached debuggers ignore-list their frames.\n // TODO: Maybe only ignore library sourcemaps if `ignoreList` is absent?\n // Though keep in mind that Turbopack omits empty `ignoreList`.\n // So if we establish this convention, we should communicate it to the ecosystem.\n ignored = true\n } else {\n // TODO: O(n^2). Consider moving `ignoreList` into a Set\n const sourceIndex = applicableSourceMap.sources.indexOf(\n sourcePosition.source\n )\n ignored = applicableSourceMap.ignoreList?.includes(sourceIndex) ?? false\n }\n\n const originalFrame: IgnoreableStackFrame = {\n // We ignore the sourcemapped name since it won't be the correct name.\n // The callsite will point to the column of the variable name instead of the\n // name of the enclosing function.\n // TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.\n methodName: frame.methodName\n ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')\n ?.replace('__webpack_exports__.', ''),\n column: sourcePosition.column,\n file: sourcePosition.source,\n lineNumber: sourcePosition.line,\n // TODO: c&p from async createOriginalStackFrame but why not frame.arguments?\n arguments: [],\n ignored,\n }\n\n const codeFrame =\n process.env.NODE_ENV !== 'production'\n ? getOriginalCodeFrame(\n originalFrame,\n sourceContent,\n inspectOptions.colors\n )\n : null\n\n return {\n stack: originalFrame,\n code: codeFrame,\n }\n}\n\nfunction parseAndSourceMap(\n error: Error,\n inspectOptions: util.InspectOptions\n): string {\n // TODO(veil): Expose as CLI arg or config option. Useful for local debugging.\n const showIgnoreListed = false\n // We overwrote Error.prepareStackTrace earlier so error.stack is not sourcemapped.\n let unparsedStack = String(error.stack)\n // We could just read it from `error.stack`.\n // This works around cases where a 3rd party `Error.prepareStackTrace` implementation\n // doesn't implement the name computation correctly.\n const errorName = computeErrorName(error)\n\n let idx = unparsedStack.indexOf('react-stack-bottom-frame')\n if (idx !== -1) {\n idx = unparsedStack.lastIndexOf('\\n', idx)\n }\n if (idx !== -1 && !showIgnoreListed) {\n // Cut off everything after the bottom frame since it'll be React internals.\n unparsedStack = unparsedStack.slice(0, idx)\n }\n\n const unsourcemappedStack = parseStack(unparsedStack)\n const sourceMapCache: SourceMapCache = new Map()\n\n let sourceMappedStack = ''\n let sourceFrameDEV: null | string = null\n for (const frame of unsourcemappedStack) {\n if (frame.file === null) {\n sourceMappedStack += '\\n' + frameToString(frame)\n } else {\n const sourcemappedFrame = getSourcemappedFrameIfPossible(\n // We narrowed this earlier by bailing if `frame.file` is null.\n frame as SourcemappableStackFrame,\n sourceMapCache,\n inspectOptions\n )\n\n if (\n process.env.NODE_ENV !== 'production' &&\n sourcemappedFrame.code !== null &&\n sourceFrameDEV === null &&\n // TODO: Is this the right choice?\n !sourcemappedFrame.stack.ignored\n ) {\n sourceFrameDEV = sourcemappedFrame.code\n }\n if (!sourcemappedFrame.stack.ignored) {\n // TODO: Consider what happens if every frame is ignore listed.\n sourceMappedStack += '\\n' + frameToString(sourcemappedFrame.stack)\n } else if (showIgnoreListed && !inspectOptions.colors) {\n sourceMappedStack += '\\n' + frameToString(sourcemappedFrame.stack)\n } else if (showIgnoreListed) {\n sourceMappedStack += '\\n' + dim(frameToString(sourcemappedFrame.stack))\n }\n }\n }\n\n return (\n errorName +\n ': ' +\n error.message +\n sourceMappedStack +\n (sourceFrameDEV !== null ? '\\n' + sourceFrameDEV : '')\n )\n}\n\nfunction sourceMapError(\n this: void,\n error: Error,\n inspectOptions: util.InspectOptions\n): Error {\n // Create a new Error object with the source mapping applied and then use native\n // Node.js formatting on the result.\n const newError =\n error.cause !== undefined\n ? // Setting an undefined `cause` would print `[cause]: undefined`\n new Error(error.message, { cause: error.cause })\n : new Error(error.message)\n\n // TODO: Ensure `class MyError extends Error {}` prints `MyError` as the name\n newError.stack = parseAndSourceMap(error, inspectOptions)\n\n for (const key in error) {\n if (!Object.prototype.hasOwnProperty.call(newError, key)) {\n // @ts-expect-error -- We're copying all enumerable properties.\n // So they definitely exist on `this` and obviously have no type on `newError` (yet)\n newError[key] = error[key]\n }\n }\n\n return newError\n}\n\nexport function patchErrorInspectNodeJS(\n errorConstructor: ErrorConstructor\n): void {\n const inspectSymbol = Symbol.for('nodejs.util.inspect.custom')\n\n errorConstructor.prepareStackTrace = prepareUnsourcemappedStackTrace\n\n // @ts-expect-error -- TODO upstream types\n // eslint-disable-next-line no-extend-native -- We're not extending but overriding.\n errorConstructor.prototype[inspectSymbol] = function (\n depth: number,\n inspectOptions: util.InspectOptions,\n inspect: typeof util.inspect\n ): string {\n // avoid false-positive dynamic i/o warnings e.g. due to usage of `Math.random` in `source-map`.\n return workUnitAsyncStorage.exit(() => {\n const newError = sourceMapError(this, inspectOptions)\n\n const originalCustomInspect = (newError as any)[inspectSymbol]\n // Prevent infinite recursion.\n // { customInspect: false } would result in `error.cause` not using our inspect.\n Object.defineProperty(newError, inspectSymbol, {\n value: undefined,\n enumerable: false,\n writable: true,\n })\n try {\n return inspect(newError, {\n ...inspectOptions,\n depth:\n (inspectOptions.depth ??\n // Default in Node.js\n 2) - depth,\n })\n } finally {\n ;(newError as any)[inspectSymbol] = originalCustomInspect\n }\n })\n }\n}\n\nexport function patchErrorInspectEdgeLite(\n errorConstructor: ErrorConstructor\n): void {\n const inspectSymbol = Symbol.for('edge-runtime.inspect.custom')\n\n errorConstructor.prepareStackTrace = prepareUnsourcemappedStackTrace\n\n // @ts-expect-error -- TODO upstream types\n // eslint-disable-next-line no-extend-native -- We're not extending but overriding.\n errorConstructor.prototype[inspectSymbol] = function ({\n format,\n }: {\n format: (...args: unknown[]) => string\n }): string {\n // avoid false-positive dynamic i/o warnings e.g. due to usage of `Math.random` in `source-map`.\n return workUnitAsyncStorage.exit(() => {\n const newError = sourceMapError(this, {})\n\n const originalCustomInspect = (newError as any)[inspectSymbol]\n // Prevent infinite recursion.\n Object.defineProperty(newError, inspectSymbol, {\n value: undefined,\n enumerable: false,\n writable: true,\n })\n try {\n return format(newError)\n } finally {\n ;(newError as any)[inspectSymbol] = originalCustomInspect\n }\n })\n }\n}\n"],"names":["findSourceMap","nativeFindSourceMap","path","url","SourceMapConsumer","SyncSourceMapConsumer","parseStack","getOriginalCodeFrame","workUnitAsyncStorage","dim","bundlerFindSourceMapPayload","undefined","setBundlerFindSourceMapImplementation","findSourceMapImplementation","frameToString","frame","sourceLocation","lineNumber","column","fileLocation","file","startsWith","URL","canParse","relative","process","cwd","fileURLToPath","methodName","computeErrorName","error","name","prepareUnsourcemappedStackTrace","structuredStackTrace","message","stack","i","length","toString","shouldIgnoreListGeneratedFrame","includes","shouldIgnoreListOriginalFrame","findApplicableSourceMapPayload","payload","frameLine","frameColumn","section","sections","offset","line","map","createUnsourcemappedFrame","arguments","ignored","code","getSourcemappedFrameIfPossible","sourceMapCache","inspectOptions","sourceMapCacheEntry","get","sourceMapConsumer","sourceMapPayload","sourceURL","pathToFileURL","maybeSourceMapPayload","sourceMap","cause","console","set","sourcePosition","originalPositionFor","source","sourceContent","sourceContentFor","applicableSourceMap","sourceIndex","sources","indexOf","ignoreList","originalFrame","replace","codeFrame","env","NODE_ENV","colors","parseAndSourceMap","showIgnoreListed","unparsedStack","String","errorName","idx","lastIndexOf","slice","unsourcemappedStack","Map","sourceMappedStack","sourceFrameDEV","sourcemappedFrame","sourceMapError","newError","Error","key","Object","prototype","hasOwnProperty","call","patchErrorInspectNodeJS","errorConstructor","inspectSymbol","Symbol","for","prepareStackTrace","depth","inspect","exit","originalCustomInspect","defineProperty","value","enumerable","writable","patchErrorInspectEdgeLite","format"],"mappings":"AAAA,SACEA,iBAAiBC,mBAAmB,QAE/B,SAAQ;AACf,YAAYC,UAAU,OAAM;AAC5B,YAAYC,SAAS,MAAK;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