{"record":{"id":"38ff5d29b5c3cc51","repo":"facebook/react","slug":"the-source-map-has-more-mappings-than-there-are-li-38ff5d","errorCode":null,"errorMessage":"The source map has more mappings than there are lines.","messagePattern":"The source map has more mappings than there are lines\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js","lineNumber":364,"sourceCode":"          exportedEntries[nextEntryIdx].originalColumn = lastOriginalColumn;\n          exportedEntries[nextEntryIdx].originalSource = lastSourceIndex;\n          exportedEntries[nextEntryIdx].nameIndex = lastNameIndex;\n        }\n      }\n\n      for (\n        let lastIdx = mappings.length - 1;\n        lastIdx >= 0 && mappings[lastIdx] === ';';\n        lastIdx--\n      ) {\n        // If the last mapped lines don't contain any segments, we don't get a callback from readMappings\n        // so we need to pad the number of mapped lines, with one for each empty line.\n        lastMappedLine++;\n      }\n\n      sourceLineCount = program.loc.end.line;\n      if (sourceLineCount < lastMappedLine) {\n        throw new Error(\n          'The source map has more mappings than there are lines.',\n        );\n      }\n      // If the original source string had more lines than there are mappings in the source map.\n      // Add some extra padding of unmapped lines so that any lines that we add line up.\n      for (\n        let extraLines = sourceLineCount - lastMappedLine;\n        extraLines > 0;\n        extraLines--\n      ) {\n        mappings += ';';\n      }\n    } else {\n      // If a file doesn't have a source map then we generate a blank source map that just\n      // contains the original content and segments pointing to the original lines.\n      sourceLineCount = 1;\n      let idx = -1;\n      while ((idx = source.indexOf('\\n', idx + 1)) !== -1) {","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server-dom-webpack/src/ReactFlightWebpackNodeLoader.js#L346-L382","documentation":"ReactFlightWebpackNodeLoader instruments 'use client'/'use server' modules and merges the file's existing source map with the mappings it inserts. As a consistency check it compares the number of mapped lines against program.loc.end.line of the actual source; if the source map claims mappings past the last line of the file, the map cannot belong to this source, so the loader refuses to continue.","triggerScenarios":"A processed file carries a sourceMappingURL whose map has more mapping lines than the file has lines — typically a map generated from a different (longer) version of the file, a misaligned transform step, or a truncated/malformed mappings field.","commonSituations":"Chained Babel/TS/SWC transforms where a later stage emits a map for the pre-transform source | Stale .map files next to regenerated sources | Tools that append or strip lines (shebang removal, banner plugins) without updating the map","solutions":["Regenerate source maps for the file so they match the current source exactly","Reorder/repair the transform chain so each stage's map corresponds to its input (source-map chaining)","If the map is expendable, remove the sourceMappingURL comment for that file so the loader skips merging","Pin consistent tool versions across the chain so map semantics do not drift"],"exampleFix":"# before: stale map next to a regenerated source\nsrc/Component.js      (edited, now 120 lines)\nsrc/Component.js.map  (maps 130 lines)\n\n# after: rebuild maps in the same pass as sources\nnpx babel src --out-dir lib --source-maps\n# or drop the stale map\nrm src/Component.js.map  # loader then skips source-map merging","handlingStrategy":"validation","validationCode":"// Pre-validate maps before the loader sees them\nimport fs from 'fs';\nfunction mapIsValid(jsPath, mapPath) {\n  const map = JSON.parse(fs.readFileSync(mapPath, 'utf8'));\n  const mappedLines = map.mappings.split(';').length;\n  const srcLines = fs.readFileSync(jsPath, 'utf8').split('\\n').length;\n  return mappedLines <= srcLines;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate sources and maps in the same toolchain pass","Chain source maps properly at every transform step","Delete orphaned .map files when sources change"],"tags":["webpack","source-maps","loader","react-server-components"],"backgroundTag":"invalid-source-map","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}