Commit cff56b6
fix(build): normalize Windows backslash paths for sourcemap resolution (#714)
## Summary
- Normalize Windows backslashes (`\`) to forward slashes (`/`) in the
telemetry `beforeSend` hook so frame paths match uploaded sourcemap
artifact URLs
- Normalize the sourcemap `sources` array during debug ID injection so
bundlers on Windows produce consistent paths
Fixes https://sentry.sentry.io/issues/7402821077/
## Problem
On Windows, Bun compiled binaries resolve `Error.stack` frame paths with
backslashes (e.g., `dist-bin\bin.js`). The `ensureAbsolute()` function
in `telemetry.ts` prepended `/` but didn't convert backslashes,
producing `/dist-bin\bin.js`. The Sentry symbolicator couldn't match
this to the uploaded artifact at `~/dist-bin/bin.js`, so sourcemaps were
never applied — stack traces showed minified function names like `ut`
with no source context.
## Changes
- **`src/lib/telemetry.ts`**: Add `.replaceAll("\\", "/")` in
`ensureAbsolute()` before the relative-path check. Covers
`frame.filename`, `frame.abs_path`, and `debug_meta.images[].code_file`.
- **`src/lib/sourcemap/debug-id.ts`**: Normalize `sources` array to
forward slashes after parsing the sourcemap JSON. Benefits both the
CLI's own build and user-facing `sentry sourcemap inject`.
- **`test/script/debug-id.test.ts`**: Two new test cases for backslash
normalization in `sources` and forward-slash preservation.
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>1 parent f7f4d71 commit cff56b6
23 files changed
Lines changed: 96 additions & 20 deletions
File tree
- .github/workflows
- plugins/sentry-cli/skills/sentry-cli
- references
- src/lib
- sourcemap
- test/script
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments