{"record":{"id":"b62e653a27682abe","repo":"vercel/next.js","slug":"unknown-source-map-type-for-filename-buffer","errorCode":null,"errorMessage":"Unknown source map type for ${filename}: ${buffer.typeFull}.","messagePattern":"Unknown source map type for (.+?): (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/dev/get-source-map-from-file.ts","lineNumber":58,"sourceCode":"  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  }\n\n  const sourceMapFilename = path.resolve(\n    path.dirname(filename),\n    decodeURIComponent(sourceUrl)\n  )\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/dev/get-source-map-from-file.ts#L40-L76","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n//# sourceMappingURL=data:text/plain;base64,eyJ2ZXJzaW9uIjozfQ==\n\n// after\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozfQ==","handlingStrategy":"validation","validationCode":"// Validate an inline data: source map before relying on it\nconst DATA_URI_RE = /^data:([^;,]+)?(;base64)?,(.*)$/\nfunction assertInlineSourceMapOk(comment: string) {\n  const m = comment.match(DATA_URI_RE)\n  if (!m) return\n  const mime = (m[1] || '').toLowerCase()\n  if (mime && mime !== 'application/json') {\n    throw new Error(`sourceMappingURL must be application/json, got ${mime}`)\n  }\n  const body = m[2] ? Buffer.from(m[3], 'base64').toString('utf8') : decodeURIComponent(m[3])\n  JSON.parse(body) // throws early if not JSON\n}\n// run in a build post-step over your compiled files' trailing comments","typeGuard":"// Narrow a raw object to a V3 source-map-shaped payload\nfunction isRawSourceMap(v: unknown): v is { version: number; sources?: unknown[]; mappings?: string } {\n  return typeof v === 'object' && v !== null && 'version' in v\n}","tryCatchPattern":"try {\n  const map = await getSourceMapFromFile(filename)\n} catch (e) {\n  // non-fatal in dev overlay: degrade to compiled source\n  console.warn('source map unavailable for', filename, (e as Error).message)\n}","preventionTips":["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."],"tags":["source-maps","dev-server","build"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}