mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
## Summary Fixes sourcemap offset issues in DevServer HMR mode that were causing incorrect line number mappings when debugging. ## Problem When using DevServer with HMR enabled, sourcemap line numbers were consistently off by one or more lines when shown in Chrome DevTools. In some cases, they were off when shown in the terminal as well. ## Solution ### 1. Remove magic +2 offset Removed an arbitrary "+2" that was added to `runtime.line_count` in SourceMapStore.zig. The comment said "magic fairy in my dreams said it would align the source maps" - this was causing positions to be incorrectly offset. ### 2. Fix double-increment bug ErrorReportRequest.zig was incorrectly adding 1 to line numbers that were already 1-based from the browser, causing an off-by-one error. ### 3. Improve type safety Converted all line/column handling to use `bun.Ordinal` type instead of raw `i32`, ensuring consistent 0-based vs 1-based conversions throughout the codebase. ## Test plan - [x] Added comprehensive sourcemap tests for complex error scenarios - [x] Tested with React applications in dev mode - [x] Verified line numbers match correctly in browser dev tools - [x] Existing sourcemap tests continue to pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>