Skip to content

feat(cli): Upload WASM source maps next to their modules as debug files - #2502

Open
Sebassmaster wants to merge 1 commit into
mainfrom
sebastianmunoz/tgdx-154-12-upload-wasm-source-maps
Open

Sebassmaster wants to merge 1 commit into
mainfrom
sebastianmunoz/tgdx-154-12-upload-wasm-source-maps

Conversation

@Sebassmaster

Copy link
Copy Markdown

sentry debug-files upload now uploads a WebAssembly module's source map along with the module. When a scanned .wasm has <module>.wasm.map next to it (where Emscripten's -gsource-map and dart2wasm write it), the map is queued as a separate debug file carrying the module's debug id. Nothing changes for modules without a map.

Sentry stores the map as a wasmsourcemap debug file next to the module (getsentry/sentry#132523), so Symbolicator can use it to symbolicate WASM frames without DWARF, which keeps compiler optimizations available. The CLI uploads the map as is: Sentry detects the format from the JSON and validates it.

The pairing relies on the module's build id. The scanner already skips modules without one, so their maps are never uploaded; the help text points to sentry wasm-split to add an id. wasm-split appends the id after all other sections and copies them byte for byte, so it never shifts the code offsets the map refers to.

Until getsentry/sentry#132523 is deployed, Sentry would file an uploaded map as an il2cpp mapping, so this should merge after it.

Question for reviewers: the map is uploaded automatically, with no flag. A map next to its module is unambiguous, and an opt-in flag is easy to forget, which then looks like broken symbolication. The alternative is an opt-in flag like --il2cpp-mapping (e.g. --wasm-sourcemaps), which keeps the upload set unchanged for existing users. Is automatic the right default?

Possible follow-ups, not in this PR:

  • Warn when a .wasm.map is found but its module has no build id, instead of skipping it silently.
  • Maps for modules scanned inside a .zip; today only on-disk neighbors are found.

This replaces the approach in #1629, which sends WASM source maps through sourcemap inject/upload as artifact bundles. Using the debug-file pipeline keeps one pairing key (the build id) for the module and its map.

Refs TGDX-154

🤖 Generated with Claude Code

debug-files upload now queues <module>.wasm.map, when it sits next to a scanned WebAssembly module, as a separate debug file with the module's debug id. Sentry detects the source map from its content and pairs it with the module by that id, so WASM apps can be symbolicated without DWARF.

Refs TGDX-154

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 25, 2026 3:19pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 25, 2026 3:19pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – sentry-local November 25, 2026 15:18 Inactive
@linear-code

linear-code Bot commented Nov 25, 2026

Copy link
Copy Markdown

TGDX-154

@Sebassmaster

Copy link
Copy Markdown
Author

Tested end to end against a local Sentry devserver running getsentry/sentry#132523:

  • Built a small C program with Emscripten 7.0.1 (emcc -O2 -gsource-map -Wl,--build-id). The optimized module keeps its build_id section, after the code section, next to a version 3 app.wasm.map.
  • debug-files upload --no-upload found both files with the same debug id, 3b5ea884-….
  • debug-files upload --wait uploaded both. Both finished as ok.
  • Sentry stored the map as wasmsourcemap under the module's debug id, and lists it with the module in /files/dsyms/?debug_id=…. Downloads match the originals byte for byte.
  • Running the upload again keeps exactly one module and one map.

🤖 Generated with Claude Code

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed for overlap with #1628 (debug-files wasm-upload) and #1629 (WASM source maps in sourcemap inject/upload). @BYK decided to ship both #1629 and this PR, so they need to fit together. They do, with one semantic conflict to fix and a merge dependency.

Semantic conflict with #1628 (whichever lands second must fix it). It merges without textual conflicts, but #1628 moves readSourceFile into debug-files/read-file.ts and drops readFileSync from the node:fs import in debug-files/upload.ts. This PR's appendWasmSourceMap still calls readFileSync, so the merged tree fails to typecheck: upload.ts(240,15): error TS2304: Cannot find name 'readFileSync'. Inline note below.

Overlap with #1629: complementary, not duplicate.

  • #1629 uploads <module>.wasm + <module>.wasm.map as an artifact bundle (minified_source + source_map) through sourcemap upload. This PR uploads the same map as a wasmsourcemap debug file through debug-files upload. Neither touches the other's files.
  • They agree on the id. debug-files upload takes the debug ID from @sentry/symbolic 14.0.0-alpha.5, and #1629's build_id decoding gives the same id. #1629 also writes that id into the map as debugId/debug_id, which getsentry/sentry#132523 prefers over the client id. A map that went through sourcemap inject first lands under the same id either way.
  • They work well in sequence: sourcemap inject (#1629) or debug-files wasm-upload (#1628) stamp a build_id into a module that has none, and that's exactly what this PR needs before it can pair the map.
  • Please drop "This replaces the approach in #1629" from the description, since both ship.

Merge dependency. getsentry/sentry#132523 is still open with changes requested, and its own description says it must wait for getsentry/symbolicator#2229 (also open) to be deployed. So the order is: symbolicator#2229 merged and deployed, then sentry#132523 approved, merged and deployed, then this PR.

On the automatic-default question: the CLI ignores CHUNK_UPLOAD_ACCEPT, and sentry#132523 adds no capability for it anyway, so the CLI can't tell whether a server knows wasmsourcemap. Any server without sentry#132523, including self-hosted installs for a while, will file the map as an il2cpp mapping under the module's debug id. That's worth weighing before making it automatic, or at least worth documenting with a minimum server version.

Non-blocking:

  • The help text points to sentry wasm-split for adding a build id. Once #1628/#1629 land, debug-files wasm-upload and sourcemap inject do that too.
  • debug-files wasm-upload (#1628) builds its own DIF list, so it won't upload the .wasm.map this PR handles. A follow-up could have it reuse appendWasmSourceMap, so the one-step command covers maps too.

}
let content: Buffer<ArrayBuffer>;
try {
content = readFileSync(mapPath);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1628 drops readFileSync from this file's node:fs import (it moves readSourceFile to ./read-file.ts). Git merges the two cleanly, but the result doesn't compile (TS2304: Cannot find name 'readFileSync'). Whichever PR lands second needs to put readFileSync back in the import.

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — 942d0a93 Deployed Nov 25, 2026 by vercel[bot]
Preview – sentry-local — 942d0a93 Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant