{"record":{"id":"f13374ae40085320","repo":"vercel/next.js","slug":"failed-to-parse-source-map-url-for-filename","errorCode":null,"errorMessage":"Failed to parse source map URL for ${filename}.","messagePattern":"Failed to parse source map URL for (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/dev/get-source-map-from-file.ts","lineNumber":52,"sourceCode":"  } catch (error) {\n    throw new Error(`Failed to read file contents of ${filename}.`, {\n      cause: error,\n    })\n  }\n\n  const sourceUrl = getSourceMapUrl(fileContents)\n\n  if (!sourceUrl) {\n    return undefined\n  }\n\n  if (sourceUrl.startsWith('data:')) {\n    let buffer: dataUriToBuffer.MimeBuffer\n\n    try {\n      buffer = dataUriToBuffer(sourceUrl)\n    } catch (error) {\n      throw new Error(`Failed to parse source map URL for ${filename}.`, {\n        cause: error,\n      })\n    }\n\n    if (buffer.type !== 'application/json') {\n      throw new Error(\n        `Unknown source map type for ${filename}: ${buffer.typeFull}.`\n      )\n    }\n\n    try {\n      return JSON.parse(buffer.toString())\n    } catch (error) {\n      throw new Error(`Failed to parse source map for ${filename}.`, {\n        cause: error,\n      })\n    }\n  }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/dev/get-source-map-from-file.ts#L34-L70","documentation":"Thrown by `getSourceMapFromFile` at line 52 when a `sourceMappingURL` extracted from a file starts with `data:` but `dataUriToBuffer(sourceUrl)` fails to parse it as a valid data URI. The original parse error is attached via `cause`. This only occurs for inline (base64/data-URI) source maps, not external `.map` files.","triggerScenarios":"A `//# sourceMappingURL=data:...` comment that is malformed (truncated, wrong encoding prefix, missing base64 payload); a corrupted build artifact; a hand-edited file with a broken inline source map.","commonSituations":"Corrupted or truncated inline source maps from a failed/minified build; third-party dependencies shipping malformed data-URI source maps; partial writes during build interruption.","solutions":["Regenerate the affected file's source map by rebuilding (clear `.next` and restart).","If the file comes from a dependency, update or report the malformed source map to the package maintainer.","Temporarily disable source map generation for the offending tool to confirm the inline map is the culprit.","Inspect the `//# sourceMappingURL=data:...` line in the reported file to ensure it is a complete, well-formed data URI."],"exampleFix":"rm -rf .next && pnpm --filter=next dev","handlingStrategy":"try-catch","validationCode":"function looksLikeDataUri(u: string): boolean {\n  return /^data:[^,]+;base64,/.test(u) || /^data:application\\/json[,;]/.test(u);\n}\nif (sourceUrl.startsWith('data:') && !looksLikeDataUri(sourceUrl)) {\n  // skip malformed inline map\n}","typeGuard":"function isValidInlineDataUri(u: string): boolean {\n  return u.startsWith('data:') && /\\S/.test(u.slice(5));\n}","tryCatchPattern":"try {\n  const map = await getSourceMapFromFile(filename);\n} catch (err) {\n  if (/Failed to parse source map URL/.test(err.message)) {\n    // inline data-URI map is malformed; fall back to no source mapping\n    return;\n  }\n  throw err;\n}","preventionTips":["Rebuild to regenerate inline source maps after build interruptions.","Report malformed inline maps from third-party packages upstream.","Treat source-map retrieval as best-effort; never let it hard-fail a request."],"tags":["source-maps","dev-server","parsing"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T01:17:05.418Z"}