{"record":{"id":"d0d2fb81f42014f8","repo":"vercel/next.js","slug":"sourceurl-invalid-source-map-only-conformant-d0d2fb","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-webpack.ts","lineNumber":331,"sourceCode":"  frame: {\n    file: string | null\n    line1: number | null\n    column1: number | null\n  },\n  options: {\n    getCompilations: () => webpack.Compilation[]\n  }\n): Promise<Source | undefined> {\n  let sourceURL = frame.file ?? ''\n  const { getCompilations } = options\n\n  sourceURL = devirtualizeReactServerURL(sourceURL)\n\n  let nativeSourceMap: SourceMap | undefined\n  try {\n    nativeSourceMap = findSourceMap(sourceURL)\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 (nativeSourceMap !== undefined) {\n    const sourceMapPayload = nativeSourceMap.payload\n    return {\n      type: 'file',\n      sourceMap: findApplicableSourceMapPayload(\n        (frame.line1 ?? 1) - 1,\n        (frame.column1 ?? 1) - 1,\n        sourceMapPayload\n      )!,\n\n      ignoredSources: getIgnoredSources(\n        // @ts-expect-error -- TODO: Support IndexSourceMap\n        sourceMapPayload","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/dev/middleware-webpack.ts#L313-L349","documentation":"Thrown by getSource in the webpack middleware source resolver when Node's findSourceMap(sourceURL) throws. This is the webpack-bundler counterpart of the Turbopack source-map error: the dev overlay/stack-trace mapper needs a conformant source map to locate original code, and findSourceMap rejected. The original error is attached as cause.","triggerScenarios":"An error overlay or stack-trace resolver calls getSource for a frame whose file URL has a source map findSourceMap cannot load. The try around findSourceMap catches and rethrows this message with the sourceURL prefix.","commonSituations":"A webpack chunk has a malformed sourceMappingURL or a referenced .map that is invalid JSON. Running webpack dev after switching from Turbopack with stale .next output. A loader emitting non-V3 source maps. Missing --enable-source-maps where findSourceMap depends on it.","solutions":["Delete .next and rebuild under webpack to regenerate valid source maps.","Verify the .map referenced by the chunk in the error message exists and is valid V3 JSON.","Run with --enable-source-maps if findSourceMap errors due to missing source-map runtime support.","Fix the webpack loader/rule producing the non-conformant map."],"exampleFix":"// before: broken inline sourceMappingURL\n//# sourceMappingURL=data:application/json,,\n\n// after: valid external V3 map\n//# sourceMappingURL=middleware.js.map","handlingStrategy":"validation","validationCode":"// Wrap findSourceMap so webpack source resolution degrades gracefully\nfunction safeFindSourceMap(url: string) {\n  try { return findSourceMap(url) } catch { return undefined }\n}","typeGuard":null,"tryCatchPattern":"try {\n  nativeSourceMap = findSourceMap(sourceURL)\n} catch (cause) {\n  throw new Error(`${sourceURL}: Invalid source map. ...`, { cause })\n}","preventionTips":["Clean .next when switching between Turbopack and webpack.","Keep --enable-source-maps on for dev.","Validate that webpack emits V3 maps for middleware chunks."],"tags":["source-maps","webpack","dev-server","error-overlay"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}