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 nativeTraceSource in the Turbopack middleware source resolver when Node's findSourceMap(frame.file) throws while looking up the source map for a stack frame. Next.js wraps the failure to explain that only conformant (V3) source maps can be used to map compiled positions back to original code. The original error is attached as cause. This affects the dev overlay/stack-frame original-code lookup for Turbopack builds.

Source

Thrown at packages/next/src/server/dev/middleware-turbopack.ts:198

    methodName: searchParams.get('methodName') ?? '<unknown>',
    line: parseInt(searchParams.get('line1') ?? '0', 10) || undefined,
    column: parseInt(searchParams.get('column1') ?? '0', 10) || undefined,
    isServer: searchParams.get('isServer') === 'true',
  }
}

/**
 * @returns 1-based lines and 1-based columns
 */
async function nativeTraceSource(
  frame: TurbopackStackFrame
): Promise<{ frame: IgnorableStackFrame; source: string | null } | undefined> {
  const sourceURL = frame.file
  let sourceMapPayload: ModernSourceMapPayload | undefined
  try {
    sourceMapPayload = findSourceMap(sourceURL)?.payload
  } catch (cause) {
    throw new Error(
      `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,
      { cause }
    )
  }

  if (sourceMapPayload !== undefined) {
    let consumer: SourceMapConsumer
    try {
      consumer = await new SourceMapConsumer(sourceMapPayload)
    } catch (cause) {
      throw new Error(
        `${sourceURL}: Invalid source map. Only conformant source maps can be used to find the original code.`,
        { cause }
      )
    }
    let traced: {
      originalPosition: NullableMappedPosition
      sourceContent: string | null

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Delete .next and rebuild so conformant V3 source maps are regenerated.
  2. Check the frame's sourceURL in the message; verify its sourceMappingURL points to a valid V3 .map.
  3. Run Node with --enable-source-maps if findSourceMap returns/errors due to missing source-map support.
  4. Disable or fix any loader/plugin that emits non-V3 source maps for that chunk.

Example fix

// before: sourceMappingURL points to invalid/non-V3 map
//# sourceMappingURL=bad.map

// after: regenerate a conformant V3 map
//# sourceMappingURL=chunk.js.map  // valid { "version": 3, ... }
Defensive patterns

Strategy: validation

Validate before calling

// Guard findSourceMap calls against throwing
function safeFindSourceMap(url: string) {
  try { return findSourceMap(url) } catch { return undefined }
}
// returns undefined instead of throwing; caller falls back to compiled source

Try / catch

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

Prevention

When it happens

Trigger: An error overlay requests the original source for a stack frame whose file URL has a source map that findSourceMap cannot load (malformed sourceMappingURL, unparseable map, or a data URI findSourceMap rejects). The try around findSourceMap catches and rethrows this message.

Common situations: A bundled module has a broken or non-V3 source map. A source map referenced by a chunk is missing or contains invalid JSON. Edge/serverless runtime differences in how findSourceMap resolves maps. Running without --enable-source-maps in a context where findSourceMap needs it.

Related errors


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