fix(build): enable sourcemap resolution for compiled binaries#701
Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Dashboard
Other
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
…isting (#632) Add a top-level 'event list' command that lists events for a Sentry issue, equivalent to 'issue events' but living in the event route. The 'sentry events' plural alias now points to this list command (Pattern A). Changes: - Extract shared types, formatters, and flag defs into event/shared-events.ts - Create event/list.ts with its own command identity (pagination hints, pagination key, and error messages say 'sentry event list') - Make buildCommandHint and resolveIssue accept optional commandBase param - Update event route to include list alongside view - Switch events plural alias from eventRoute to eventListCommand - Remove stale event/list synonym from command-suggestions.ts - Add 6 func tests verifying output, pagination hints, and command identity
…_MIN_LIMIT/LIST_DEFAULT_LIMIT Every list command duplicated MAX_LIMIT (1000), MIN_LIMIT (1), and DEFAULT_LIMIT (varying 20-100) locally. Move them to list-command.ts as LIST_MAX_LIMIT, LIST_MIN_LIMIT, and LIST_DEFAULT_LIMIT (standardized to 25). - trace list default: 20 → 25 - trace logs default: 100 → 25 - log list default: 100 → 25 - buildListLimitFlag default: 30 → 25 - issue list: remove redundant explicit "25" (now the default)
db23972 to
f073da7
Compare
|
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ❌ Patch coverage is 72.09%. Project has 1525 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 95.38% 95.35% -0.03%
==========================================
Files 225 225 —
Lines 32783 32825 +42
Branches 0 0 —
==========================================
+ Hits 31269 31300 +31
- Misses 1514 1525 +11
- Partials 0 0 —Generated by Codecov Action |
f073da7 to
1d5c768
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1d5c768. Configure here.
Fix four issues preventing sourcemaps from working in Bun-compiled binaries: 1. Events had no debug_meta because the IIFE snippet was placed before ESM imports (invalid ESM). Register debug IDs at module scope via build-time constant instead. 2. Artifact bundle ZIPs lacked the SYSB magic header required by the symbolic crate's SourceBundle parser. Add the 8-byte header in ZipWriter. 3. Bun.build reformats code (3.7k → 40k lines), breaking sourcemap positions. Use sourcemap: "linked" to embed a map in the binary that Bun's runtime uses to auto-resolve Error.stack positions back to esbuild output coordinates. 4. Bun's embedded map produces relative paths in Error.stack (e.g., "dist-bin/bin.js"). The symbolicator's URL candidate generator skips relative paths silently. Normalize to absolute in beforeSend.
1d5c768 to
f9dffc6
Compare

Summary
Fixes sourcemap resolution for the Sentry CLI's Bun-compiled binaries. Error events now show original TypeScript file paths, line numbers, and function names instead of minified code.
Before:
at ySt (/$bunfs/root/bin.js:40106:19)After:
at resolveProjectSearchFallback (../src/commands/issue/utils.ts:165:15)What was wrong
Four distinct issues prevented sourcemaps from working:
1. No
debug_metain eventsThe debug ID IIFE snippet was injected before ESM
importdeclarations, creating invalid ESM that Bun's compiler dropped. Events had nodebug_meta— the server couldn't even attempt resolution.Fix: Register debug IDs at module scope in
constants.tsvia a build-time__SENTRY_DEBUG_ID__constant (esbuilddefinewith placeholder UUID, replaced after sourcemap hash computation).2. Artifact bundle ZIP format
Our
ZipWriterproduced plain ZIPs. The symbolicator uses thesymboliccrate which requires an 8-byteSYSBmagic header before the ZIP data.Fix:
ZipWriter.create()writes the SYSB header.3. Line/column position mismatch
Bun.build({ compile: true })reformats code (3.7k lines → 40k lines), making esbuild's sourcemap positions invalid.Fix:
sourcemap: "linked"inBun.buildembeds a map in the binary. Bun's runtime auto-resolvesError.stackpositions back to esbuild output coordinates. The esbuild map is saved beforeBun.build(which overwritesbin.js.map) and restored after.4. Symbolicator silently skips relative paths
Bun's embedded map resolves to relative paths (
dist-bin/bin.js). The symbolicator's URL candidate generator produces~dist-bin/bin.js(missing/after~) for relative paths, which never matches uploaded artifacts.Fix:
beforeSendnormalizes relative frame paths anddebug_meta.images[].code_fileto absolute by prepending/.Verification
Built locally, triggered an error, verified in Sentry:
resolveProjectSearchFallback../src/commands/issue/utils.ts:165:15Event: https://sentry.sentry.io/issues/7398675564/events/0192a9a1d94f43519ee697e566f08b92/