Skip to content

feat(sourcemap): Add wasm sourcemap support for inject and upload - #1629

Draft
sentry-junior[bot] wants to merge 1 commit into
port/cli-1572-wasm-uploadfrom
port/cli-1588-wasm-sourcemaps
Draft

sentry-junior[bot] wants to merge 1 commit into
port/cli-1572-wasm-uploadfrom
port/cli-1588-wasm-sourcemaps

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Ported from getsentry/cli#1588 by @d2anamaria, which is being closed as part of the getsentry/cli archive. This PR is stacked on #1628 (the port of cli#1572) and should merge after it. It is a draft because the original was a draft, and nobody had reviewed it yet.

Problem

sentry sourcemap inject and sentry sourcemap upload only look for .js, .cjs, and .mjs files. When Emscripten builds with -gsource-map, it writes an app.wasm.map file, and these commands never upload it. Even when the map gets to Sentry some other way, nothing links it to its module. Events identify a wasm module by its build_id custom section, but uploaded sourcemaps are matched by the debug_id inside the map JSON.

Solution

Both commands now handle <stem>.wasm + <stem>.wasm.map pairs next to JavaScript pairs.

  • The module's build_id decides the id. The CLI formats it as a dashed UUID and writes it into the map as debug_id / debugId.
  • A module with no build_id gets a random one first.
  • The module itself is never read as text.
  • Running the commands again changes nothing. If a map already has a different id, the module's id replaces it.
  • upload sends the module as minified_source and the map as source_map, both under the same id. --url-prefix, --strip-prefix, --strip-common-prefix, --release, and --dist all work for these pairs.
  • *.debug.wasm companions are skipped, because debug-files wasm-upload uploads them.
  • A directory without wasm behaves exactly as before.

Build-id stamping moves to lib/wasm/stamp.ts, so wasm-upload and the sourcemap path follow the same rule.

Port notes

  • Conflicts were resolved against toolkit's newer runtime-registration and inline-sourcemap handling. The help text keeps toolkit's wording, and --strip-common-prefix still handles inline maps.
  • setSourcemapDebugId calls toolkit's mutateSourcemap without snippetLine, so mappings are not shifted. In the original PR this was the offsetMappings: false option.
  • Bot findings on cli#1588 that this PR still has:
    • addWasmDiscoveryCounts ignores --ignore / --ignore-file. If a directory's only .wasm files are ignored, the error message about missing maps can be misleading.
    • With --dry-run, wasm pairs show as unchanged even when the command would stamp them, because mapWritten and moduleStamped are never set during a dry run.
  • Known limitations, carried over from the original PR:
    • Pairs are found by filename only. The module's sourceMappingURL section is not parsed.
    • Inline (data-URL) wasm sourcemaps are not supported.

Validation

  • tsc --noEmit for packages/cli
  • vitest across test/lib/wasm, test/commands/debug-files, test/commands/sourcemap, test/lib/sourcemap, test/lib/scan: 593 tests passed
  • oxlint and oxfmt --check for packages/cli
  • generate:docs leaves no diff

Refs getsentry/cli#1588

via BYK.

--

View Junior Session in Sentry

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 23, 2026 2:03pm UTC

Request Review

`sourcemap inject` and `sourcemap upload` only discovered `.js`, `.cjs`,
and `.mjs`, so the `app.wasm.map` Emscripten writes with `-gsource-map`
never reached Sentry. Even when it did, nothing linked it to its module:
events identify a wasm module by its `build_id` custom section, while
sourcemaps match by the `debug_id` inside the map JSON.

Both commands now handle `<stem>.wasm` + `<stem>.wasm.map` pairs next to
JS pairs. The module's `build_id` is the source of truth. The CLI formats
it as a dashed UUID and writes it onto the map as `debug_id`/`debugId`,
stamping a random `build_id` first when the module has none. The module
is never read as text. Running it again changes nothing, and if the map
already has a different id, the module's id replaces it. `upload` sends
the module as `minified_source` and the map as `source_map` under that
id. `*.debug.wasm` companions are skipped because `debug-files
wasm-upload` owns them.

Build id stamping moves to `lib/wasm/stamp.ts` so `wasm-upload` and the
sourcemap path share one rule.

Ported from getsentry/cli#1588, which is being closed with the repo
archive. Stacked on the getsentry/cli#1572 port.
@sentry-junior
sentry-junior Bot force-pushed the port/cli-1588-wasm-sourcemaps branch from 9a44113 to 39c9a29 Compare October 23, 2026 14:03

This branch was previously deployed

1 inactive deployment
Preview — 39c9a294 Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants