Repository navigation
feat(debug-files): Store WASM source maps as debug files - #132523
Sebassmaster wants to merge 10 commits into
Conversation
Files starting with { were all stored as il2cpp. Parse the JSON once and treat
source maps (version 3, no index maps) as wasmsourcemap, with a normalized debug id.
Refs TGDX-153
Also create the wasmsourcemap extension test's models through the test factories. Refs TGDX-153
The map shares its debug id with the .wasm module but has no features, so the generic cleanup rule deleted it whenever the module was uploaded after it. Keep only the newest map per debug id, like il2cpp. Refs TGDX-153
There was a problem hiding this comment.
Very nice start! I only have one criticism:
Like il2cpp, the map carries no id of its own
This isn't quite true, sourcemaps can contain debug IDs (under the key "debugId"). Whether a sourcemap emitted by a WASM compiler actually does that is a different question, but I believe we should handle this case from the start. I would give the ID contained in the map precedence over one that is passed separately.
|
Tested end to end against a local devserver running this branch, with the CLI from getsentry/toolkit#2502:
🤖 Generated with Claude Code |
…e a module clean_redundant_difs kept the newest file by position, so when a companion file (a WASM source map, il2cpp mapping, BCSymbolMap or UUID map) was the newest, an older module with no features compared against an empty feature set and was deleted. A fully stripped WASM module uploaded before its source map hit this. Only files handled by the generic rule now count as newer. Refs TGDX-153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Source maps can carry their own debug id in debugId (the source map debug id proposal) or the legacy debug_id key, and Emscripten fills it with the module's build id. That id now takes precedence over the one the client sends, so the client no longer has to send one for such maps. A malformed embedded id rejects the upload, and an id that differs from the client's is logged, since the map would then not pair with its module. Refs TGDX-153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Good catch, thanks. Done in 372958d: the map's own This turned out to matter in practice: a current Emscripten ( One thing I'd like your view on: if the embedded id differs from the one the client sends, the map is stored under the embedded id, and Symbolicator, which looks up the module's build id, never finds it next to the module. For now I log a warning in that case. Would you rather reject such uploads? I also updated the PR description. 🤖 Generated with Claude Code |
For native debug files (like WASM files) we take the included ID as the truth and only allow overriding if they agree on the first 36 characters (everything except the age part), cf. sentry/src/sentry/models/debugfile.py Lines 781 to 783 in 9d841fe I don't believe sourcemap debug IDs ever even have an age, so we should just take the embedded debug ID if it's present and only use the user-supplied one as a substitute if it's missing. |
Got that,
Got that, we are already implementing that logic (embedded taking precedence over user supplied one), so we are good in this regards. |
…noz/tgdx-153-11-add-wasm-source-maps-as-a-new
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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 1a69dd2. Configure here.
Events from SDKs with the old WASM build id bug look files up by the legacy id. The module stores it, but the map did not, so those events found the module without its map. Refs TGDX-153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thank you for catching this, this has been handled in 372958d. |

Important
Don't merge until getsentry/symbolicator#2229 is deployed. Symbolicator fails to parse a debug file list that contains an unknown
symbolType, which would hide the.wasmmodule itself. That is what happened withdartsymbolmapin getsentry/symbolicator#1803.Sentry now stores WASM source maps (
.wasm.map, as written by Emscripten and dart2wasm) as debug files, with the new formatwasmsourcemap. They are uploaded through the regular DIF assemble endpoint and served from/files/dsyms/, so Symbolicator can find them by debug id next to the.wasmmodule. Symbolicator doesn't use them yet; that comes later in the project. This lets WASM apps symbolicate from a source map instead of DWARF, which blocks the compiler's full optimizations.Until now every uploaded JSON object (anything starting with
{) was stored as an il2cpp line mapping, so a source map would have been silently misfiled.determine_dif_kindcan only see the first bytes, so the decision now happens after the JSON is parsed:DifKind.Il2Cppis renamed toDifKind.JsonObject, which says what the sniff actually knows.versionandmappings(orsections) is treated as a source map. Any other JSON object is still il2cpp, with unchanged behavior.sections) are rejected. Both get an explicit upload error instead of falling back to il2cpp.debugId(or the legacydebug_id) when it has one: Emscripten fills it with the module's build id. Otherwise the client must senddebug_id(the.wasmbuild id). Either way the id is normalized, because Symbolicator looks files up by exact match on the normalized id. An embedded id that differs from the client's wins and is logged, since such a map would not pair with its module.Two things worth a look in review:
clean_redundant_difswould delete it whenever the module is uploaded after it. il2cpp had the same bug (fix: Prevent il2cpp DIFs from being cleaned #35843). Maps now only replace older maps. The generic rule also no longer counts a newer companion file (map, il2cpp, BCSymbolMap, UUID map) as the newer file, which could delete a module without features, such as a fully stripped.wasmuploaded before its map.data={"features": []}. A non-nulldatakeeps checksum dedup working. I left out"mapping"on purpose: the Dart lookup (find_by_debug_ids(..., features=["mapping"])) doesn't filter by format, and could otherwise pick up a WASM source map that shares a debug id with a Dart symbol map.The frontend label for the new type will be a separate PR.
Refs TGDX-153
🤖 Generated with Claude Code