vercel/next.js · error
Unknown source map type for ${filename}: ${buffer.typeFull}.
Error message
Unknown source map type for ${filename}: ${buffer.typeFull}. What it means
Thrown by getSourceMapFromFile when an inline (data: URI) source map's MIME type is not 'application/json'. Next.js reads source maps from compiled files to power the dev overlay's original-code view; when the sourceMappingURL is a data: URI, the dataUriToBuffer parser extracts a type, and anything other than application/json is rejected. The original cause is not chained here because there is no thrown error, only an unexpected MIME type. It surfaces during dev-only source map resolution.
Source
Thrown at packages/next/src/server/dev/get-source-map-from-file.ts:58
const sourceUrl = getSourceMapUrl(fileContents)
if (!sourceUrl) {
return undefined
}
if (sourceUrl.startsWith('data:')) {
let buffer: dataUriToBuffer.MimeBuffer
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)
)
View on GitHub (pinned to 0ae8c72462)
Solutions
- Delete .next and rebuild so the bundler regenerates conformant source maps.
- Find the offending file in the error message, inspect its trailing sourceMappingURL data URI, and confirm its MIME is application/json.
- Disable or fix the custom loader/plugin that is rewriting source map annotations to a non-JSON content type.
- Switch that file to an external .map file (//# sourceMappingURL=foo.js.map) instead of an inline data URI.
Example fix
// before //# sourceMappingURL=data:text/plain;base64,eyJ2ZXJzaW9uIjozfQ== // after //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozfQ==
Defensive patterns
Strategy: validation
Validate before calling
// Validate an inline data: source map before relying on it
const DATA_URI_RE = /^data:([^;,]+)?(;base64)?,(.*)$/
function assertInlineSourceMapOk(comment: string) {
const m = comment.match(DATA_URI_RE)
if (!m) return
const mime = (m[1] || '').toLowerCase()
if (mime && mime !== 'application/json') {
throw new Error(`sourceMappingURL must be application/json, got ${mime}`)
}
const body = m[2] ? Buffer.from(m[3], 'base64').toString('utf8') : decodeURIComponent(m[3])
JSON.parse(body) // throws early if not JSON
}
// run in a build post-step over your compiled files' trailing comments Type guard
// Narrow a raw object to a V3 source-map-shaped payload
function isRawSourceMap(v: unknown): v is { version: number; sources?: unknown[]; mappings?: string } {
return typeof v === 'object' && v !== null && 'version' in v
} Try / catch
try {
const map = await getSourceMapFromFile(filename)
} catch (e) {
// non-fatal in dev overlay: degrade to compiled source
console.warn('source map unavailable for', filename, (e as Error).message)
} Prevention
- Let the bundler emit source maps; do not hand-author sourceMappingURL data URIs.
- Regenerate .next after changing source-map-related config.
- Prefer external .map files over inline data URIs for compiled output.
When it happens
Trigger: A compiled chunk contains a sourceMappingURL comment whose data: URI uses a non-JSON MIME type (e.g. data:text/plain;base64,... or data:application/octet-stream;...). Triggered when the dev server/overlay tries to read the source map for that file via getSourceMapFromFile.
Common situations: A custom SWC/babel/loader plugin or post-processing step emits inline source maps with an unusual content type. Manually-authored sourceMappingURL data URIs. Corruption of the sourceMappingURL annotation by a CDN or minifier that re-encodes the data URI.
Related errors
- Failed to read file contents of ${filename}.
- Failed to parse source map URL for ${filename}.
- Failed to parse source map for ${filename}.
- Failed to parse source map ${sourceMapFilename}.
- ${sourceURL}: Invalid source map. Only conformant source map
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/b62e653a27682abe.
Report an issue: GitHub.