{"record":{"id":"493f04926cecbca3","repo":"facebook/react","slug":"section-offsets-must-be-ordered-and-non-overlappin","errorCode":null,"errorMessage":"Section offsets must be ordered and non-overlapping.","messagePattern":"Section offsets must be ordered and non-overlapping\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-devtools-shared/src/hooks/SourceMapConsumer.js","lineNumber":170,"sourceCode":"  } = {\n    line: -1,\n    column: 0,\n  };\n\n  const sections: Array<Section> = sourceMapJSON.sections.map(section => {\n    const offset: {\n      line: number,\n      column: number,\n      ...\n    } = section.offset;\n    const offsetLine0 = offset.line;\n    const offsetColumn0 = offset.column;\n\n    if (\n      offsetLine0 < lastOffset.line ||\n      (offsetLine0 === lastOffset.line && offsetColumn0 < lastOffset.column)\n    ) {\n      throw new Error('Section offsets must be ordered and non-overlapping.');\n    }\n\n    lastOffset = offset;\n\n    return {\n      offsetLine0,\n      offsetColumn0,\n      map: section.map,\n      sourceMapConsumer: null,\n    };\n  });\n\n  function originalPositionFor({\n    columnNumber,\n    lineNumber,\n  }: SearchPosition): ResultPosition {\n    // Error.prototype.stack columns are 1-based (like most IDEs) but ASTs are 0-based.\n    const column0 = columnNumber - 1;","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-devtools-shared/src/hooks/SourceMapConsumer.js#L152-L188","documentation":"The DevTools source-map consumer implements indexed source maps by binary-searching sections, which per the TC39 source-map spec requires sections to be sorted by offset and non-overlapping. When constructing the consumer it walks sections in order and throws as soon as one starts before the previous section's offset — a malformed map, not a bad lookup.","triggerScenarios":"Passing an indexed source map whose sections array is out of order or overlapping to SourceMapConsumer()/parseHookNames — e.g. produced by a concatenating bundler, a buggy sourcemap-merge plugin, an incremental build with stale sections, or a hand-edited map.","commonSituations":"Hook-name resolution (DevTools 'parse hook names') against apps whose toolchain emits indexed maps (concatenation, multi-pass builds); upgrading a bundler changes map emission; third-party dependencies shipping unsorted indexed maps.","solutions":["Regenerate the source map with a fixed/updated toolchain — ordered sections are a spec requirement, not a preference.","Pre-sort sections by (line, column) offset before handing the JSON to the consumer.","If the toolchain cannot guarantee order, emit a flat (non-indexed) map instead.","If the map cannot be fixed, disable hook-name parsing in DevTools so the map is never consumed."],"exampleFix":"// before\nconst consumer = SourceMapConsumer(sourceMapJSON);\n\n// after — enforce the ordering the spec requires\nsourceMapJSON.sections.sort((a, b) =>\n  a.offset.line - b.offset.line || a.offset.column - b.offset.column,\n);\nconst consumer = SourceMapConsumer(sourceMapJSON);","handlingStrategy":"validation","validationCode":"function sectionsAreOrdered(sections) {\n  let last = {line: -1, column: 0};\n  return sections.every(section => {\n    const {line, column} = section.offset;\n    const ok =\n      line > last.line || (line === last.line && column >= last.column);\n    last = {line, column};\n    return ok;\n  });\n}\nif (sectionsAreOrdered(map.sections)) {\n  const consumer = SourceMapConsumer(map);\n}","typeGuard":"function sectionsAreOrdered(sections) {\n  let last = {line: -1, column: 0};\n  return sections.every(section => {\n    const {line, column} = section.offset;\n    const ok =\n      line > last.line || (line === last.line && column >= last.column);\n    last = {line, column};\n    return ok;\n  });\n}","tryCatchPattern":"try {\n  const consumer = SourceMapConsumer(sourceMapJSON);\n} catch (error) {\n  if (/Section offsets must be ordered/.test(error.message)) {\n    sourceMapJSON.sections.sort((a, b) =>\n      a.offset.line - b.offset.line || a.offset.column - b.offset.column,\n    );\n    consumer = SourceMapConsumer(sourceMapJSON);\n  } else {\n    throw error;\n  }\n}","preventionTips":["Regenerate maps with toolchains that emit spec-compliant ordered sections.","Validate section ordering in a build step before shipping maps.","Prefer flat source maps when concatenation order is not guaranteed."],"tags":["devtools","source-map","indexed-source-map","hooks","bundler"],"backgroundTag":"malformed-source-map","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}