vercel/next.js · error

${sourceURL}: Invalid source map. Only conformant source map

Error message

${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.

What it means

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.

Source

Thrown at packages/next/src/server/dev/middleware-webpack.ts:331

  frame: {
    file: string | null
    line1: number | null
    column1: number | null
  },
  options: {
    getCompilations: () => webpack.Compilation[]
  }
): Promise<Source | undefined> {
  let sourceURL = frame.file ?? ''
  const { getCompilations } = options

  sourceURL = devirtualizeReactServerURL(sourceURL)

  let nativeSourceMap: SourceMap | undefined
  try {
    nativeSourceMap = findSourceMap(sourceURL)
  } catch (cause) {
    throw new Error(
      `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,
      { cause }
    )
  }

  if (nativeSourceMap !== undefined) {
    const sourceMapPayload = nativeSourceMap.payload
    return {
      type: 'file',
      sourceMap: findApplicableSourceMapPayload(
        (frame.line1 ?? 1) - 1,
        (frame.column1 ?? 1) - 1,
        sourceMapPayload
      )!,

      ignoredSources: getIgnoredSources(
        // @ts-expect-error -- TODO: Support IndexSourceMap
        sourceMapPayload

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Delete .next and rebuild under webpack to regenerate valid source maps.
  2. Verify the .map referenced by the chunk in the error message exists and is valid V3 JSON.
  3. Run with --enable-source-maps if findSourceMap errors due to missing source-map runtime support.
  4. Fix the webpack loader/rule producing the non-conformant map.

Example fix

// before: broken inline sourceMappingURL
//# sourceMappingURL=data:application/json,,

// after: valid external V3 map
//# sourceMappingURL=middleware.js.map
Defensive patterns

Strategy: validation

Validate before calling

// Wrap findSourceMap so webpack source resolution degrades gracefully
function safeFindSourceMap(url: string) {
  try { return findSourceMap(url) } catch { return undefined }
}

Try / catch

try {
  nativeSourceMap = findSourceMap(sourceURL)
} catch (cause) {
  throw new Error(`${sourceURL}: Invalid source map. ...`, { cause })
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/d0d2fb81f42014f8. Report an issue: GitHub.