Repository navigation
feat(sourcemap): Add wasm sourcemap support for inject and upload - #1629
Draft
sentry-junior[bot] wants to merge 7 commits into
Draft
sentry-junior[bot] wants to merge 7 commits into
sentry-junior[bot] wants to merge 7 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
sentry-junior
Bot
force-pushed
the
port/cli-1588-wasm-sourcemaps
branch
from
October 23, 2026 13:39
a3b4624 to
9a44113
Compare
`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
Bot
force-pushed
the
port/cli-1588-wasm-sourcemaps
branch
from
October 23, 2026 14:03
9a44113 to
39c9a29
Compare
Bring in main through the rebased #1628 and fit wasm pairs into what landed there: - `sourcemap upload <glob>` now narrows wasm pairs the way it narrows JS pairs: a pair is kept when the module or its map matches, and the zero-pairs diagnostic counts only matching files so the `.wasm.map` subtraction lines up with the JS tally. - `--dry-run` now reports what a real run would change. `mapWritten` and `moduleStamped` were always false in a dry run, so `sourcemap inject --dry-run` counted every wasm pair as skipped. `setSourcemapDebugId` returns `changed` instead of `written` to say the same in both modes. - `relativePosix` is shared with JS discovery instead of duplicated. Co-Authored-By: bete <28983162+betegon@users.noreply.github.com> Co-Authored-By: BYK <burak.kaya@sentry.io>
…cemaps Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>
A .wasm that isn't a module or a .wasm.map that isn't JSON threw a raw error after the JS files had already been rewritten, so nothing was uploaded and the crash reached Sentry as unexpected. Skip such a pair with a warning, as the JS path does for a bad inline map, and leave it out of the upload. Also skip a module whose build_id section exists but can't be read: stamping it would add a second build_id, and symbolic and @sentry/wasm read different ones. Check the map before stamping so a skipped pair writes nothing, accept maps saved with a BOM, warn when a build_id is too short to form a debug ID, and replace modules and maps through a temp file and rename so an interrupted write can't leave a corrupt artifact. Co-Authored-By: bete <28983162+betegon@users.noreply.github.com> Co-Authored-By: BYK <burak.kaya@sentry.io>
…cemaps Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>
wasm-upload now only treats <stem>.<build_id>.debug.wasm as its own companion, so a plain app.debug.wasm debug build gets paired with its map instead of being skipped. Update the fixtures and cover that case. Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ported from getsentry/cli#1588 by @d2anamaria, which is being closed as part of the
getsentry/cliarchive. 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 injectandsentry sourcemap uploadonly look for.js,.cjs, and.mjsfiles. When Emscripten builds with-gsource-map, it writes anapp.wasm.mapfile, 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 itsbuild_idcustom section, but uploaded sourcemaps are matched by thedebug_idinside the map JSON.Solution
Both commands now handle
<stem>.wasm+<stem>.wasm.mappairs next to JavaScript pairs.build_iddecides the id. The CLI formats it as a dashed UUID and writes it into the map asdebug_id/debugId.build_idgets a random one first.uploadsends the module asminified_sourceand the map assource_map, both under the same id.--url-prefix,--strip-prefix,--strip-common-prefix,--release, and--distall work for these pairs.*.debug.wasmcompanions are skipped, becausedebug-files wasm-uploaduploads them.Build-id stamping moves to
lib/wasm/stamp.ts, sowasm-uploadand the sourcemap path follow the same rule.Port notes
--strip-common-prefixstill handles inline maps.setSourcemapDebugIdcalls toolkit'smutateSourcemapwithoutsnippetLine, somappingsare not shifted. In the original PR this was theoffsetMappings: falseoption.--dry-run, wasm pairs showed as unchanged even when the command would stamp them.mapWrittenandmoduleStampednow report what a real run would do, asinjecteddoes for JS.addWasmDiscoveryCountsignoring--ignore/--ignore-file: kept on purpose. The JS diagnostic doesn't apply them either, and the.wasm.mapcount is subtracted from the JS tally, so both walks have to see the same files.sentry sourcemap upload './dist/**') narrows wasm pairs the same way it narrows JS pairs. A pair is kept when the module or its map matches.sourceMappingURLsection is not parsed.sentry-cli v3 compatibility
sourcemaps uploadincludesmapin its default extensions, so it uploadedapp.wasm.mapby URL. v4 on main drops it. This PR brings it back, paired with the module..wasmfiles fromsourcemaps inject/upload. This PR stamps abuild_idinto modules that have none.--no-rewritekeeps the v3 behavior: nothing is written, and the pair uploads by URL with whatever id the module already has.build_idconvention (getsentry/symbolic#1069)The map is keyed by the convention-correct id, decoded from the
build_idvector. The other readers now agree:@sentry/wasmsince fix(wasm): Skip length prefix in 16-byte build IDs sentry-javascript#24857 (11.11.0)Caveats:
@sentry/wasm11.12.0 strips the length byte only from 16-byte ids. Modules linked withwasm-ld --build-id=sha1(20 bytes) still report a shifted id, and that has to be fixed in the SDK.Review fixes
build_id(written before the length prefix was standardized) is read as is, matching symbolic. Before, such a module got a second, randombuild_id, and symbolic and the SDK then read different ones. The fix is in feat(debug-files): Add wasm-upload command for WASM debug setup #1628 (lib/wasm/binary.ts) and is merged here..wasmthat isn't a module, a map that isn't JSON, an unreadablebuild_id, or files that can't be written. Before, it threw after the JS files had already been rewritten. The map is checked before the module is stamped, so a skipped pair writes nothing.build_idtoo short to form a debug ID produces a warning.rename, so an interrupted write can't leave a corrupt artifact.End-to-end check
Real Emscripten builds were run through the bundled CLI from this branch, uploading to a mock Sentry. Each module was then crashed in headless Chromium with
@sentry/wasm.build_id@sentry/wasm11.12.0--build-id=uuid/fastcrash.c:7:4--build-id=sha1(20 bytes)crash.c:7:4crash.c:7:4crash.c:7:4Validation
tsc --noEmitforpackages/clivitestfortest/libandtest/commands: everything passes except 6 cases that fail only in this sandbox (root permissions, delta-upgrade e2e) and are unrelated to this changeci:policyoxlintandoxfmt --checkforpackages/cligenerate:docsleaves no diffRefs getsentry/cli#1588
via BYK, @betegon.
--
View Session [Sentry]