{"record":{"id":"30832c953be9debb","repo":"vercel/next.js","slug":"sourceurl-invalid-source-map-only-conformant","errorCode":null,"errorMessage":"${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.","messagePattern":"(.+?): Invalid source map\\. Only conformant source maps can be used to find the original code\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/dev/middleware-turbopack.ts","lineNumber":198,"sourceCode":"    methodName: searchParams.get('methodName') ?? '<unknown>',\n    line: parseInt(searchParams.get('line1') ?? '0', 10) || undefined,\n    column: parseInt(searchParams.get('column1') ?? '0', 10) || undefined,\n    isServer: searchParams.get('isServer') === 'true',\n  }\n}\n\n/**\n * @returns 1-based lines and 1-based columns\n */\nasync function nativeTraceSource(\n  frame: TurbopackStackFrame\n): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {\n  const sourceURL = frame.file\n  let sourceMapPayload: ModernSourceMapPayload | undefined\n  try {\n    sourceMapPayload = findSourceMap(sourceURL)?.payload\n  } catch (cause) {\n    throw new Error(\n      `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n      { cause }\n    )\n  }\n\n  if (sourceMapPayload !== undefined) {\n    let consumer: SourceMapConsumer\n    try {\n      consumer = await new SourceMapConsumer(sourceMapPayload)\n    } catch (cause) {\n      throw new Error(\n        `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,\n        { cause }\n      )\n    }\n    let traced: {\n      originalPosition: NullableMappedPosition\n      sourceContent: string | null","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/dev/middleware-turbopack.ts#L180-L216","documentation":"Thrown by nativeTraceSource in the Turbopack middleware source resolver when Node's findSourceMap(frame.file) throws while looking up the source map for a stack frame. Next.js wraps the failure to explain that only conformant (V3) source maps can be used to map compiled positions back to original code. The original error is attached as cause. This affects the dev overlay/stack-frame original-code lookup for Turbopack builds.","triggerScenarios":"An error overlay requests the original source for a stack frame whose file URL has a source map that findSourceMap cannot load (malformed sourceMappingURL, unparseable map, or a data URI findSourceMap rejects). The try around findSourceMap catches and rethrows this message.","commonSituations":"A bundled module has a broken or non-V3 source map. A source map referenced by a chunk is missing or contains invalid JSON. Edge/serverless runtime differences in how findSourceMap resolves maps. Running without --enable-source-maps in a context where findSourceMap needs it.","solutions":["Delete .next and rebuild so conformant V3 source maps are regenerated.","Check the frame's sourceURL in the message; verify its sourceMappingURL points to a valid V3 .map.","Run Node with --enable-source-maps if findSourceMap returns/errors due to missing source-map support.","Disable or fix any loader/plugin that emits non-V3 source maps for that chunk."],"exampleFix":"// before: sourceMappingURL points to invalid/non-V3 map\n//# sourceMappingURL=bad.map\n\n// after: regenerate a conformant V3 map\n//# sourceMappingURL=chunk.js.map  // valid { \"version\": 3, ... }","handlingStrategy":"validation","validationCode":"// Guard findSourceMap calls against throwing\nfunction safeFindSourceMap(url: string) {\n  try { return findSourceMap(url) } catch { return undefined }\n}\n// returns undefined instead of throwing; caller falls back to compiled source","typeGuard":null,"tryCatchPattern":"try {\n  sourceMapPayload = findSourceMap(sourceURL)?.payload\n} catch (cause) {\n  throw new Error(`${sourceURL}: Invalid source map. ...`, { cause })\n}","preventionTips":["Run Node with --enable-source-maps where findSourceMap is required.","Ensure all chunks ship V3 source maps.","Clean .next before debugging source-map-related overlay errors."],"tags":["source-maps","turbopack","dev-server","error-overlay"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}