vercel/next.js · error · Error
Failed to parse source map for
Error message
Failed to parse source map for ${filename}. What it means
Wrapper in getSourceMapFromFile: the inline data: URI source map decoded successfully but JSON.parse rejected its contents. The parse error is attached as cause; the artifact embeds syntactically invalid JSON as its source map.
Solutions
- Ensure the referenced source map is valid JSON; regenerate it with the bundler.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Parsing an inline or external source map fails.
Common situations: Corrupted source map data encountered while formatting dev error stacks.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/7ba850b2d584fa95.
Report an issue: GitHub.
Appendix: source
Thrown at packages/next/src/server/dev/get-source-map-from-file.ts:66
try {
buffer = dataUriToBuffer(sourceUrl)
} catch (error) {
throw new Error(`Failed to parse source map URL for ${filename}.`, {
cause: error,
})
}
if (buffer.type !== 'application/json') {
throw new Error(
`Unknown source map type for ${filename}: ${buffer.typeFull}.`
)
}
try {
return JSON.parse(buffer.toString())
} catch (error) {
throw new Error(`Failed to parse source map for ${filename}.`, {
cause: error,
})
}
}
const sourceMapFilename = path.resolve(
path.dirname(filename),
decodeURIComponent(sourceUrl)
)
try {
const sourceMapContents = await fs.readFile(sourceMapFilename, 'utf-8')
return JSON.parse(sourceMapContents.toString())
} catch (error) {
throw new Error(`Failed to parse source map ${sourceMapFilename}.`, {
cause: error,
})View on GitHub (pinned to 0eb3775416)