Skip to content

fix(wasm): map wasm:// stack frames to registered debug images - #23999

Draft
d2anamaria wants to merge 10 commits into
developfrom
ana/fix/wasm-worker-non-streaming
Draft

fix(wasm): map wasm:// stack frames to registered debug images#23999
d2anamaria wants to merge 10 commits into
developfrom
ana/fix/wasm-worker-non-streaming

Conversation

@d2anamaria

Copy link
Copy Markdown

Problem

Buffer-compiled wasm (fetch → arrayBuffer → instantiate, common in workers) often shows up in stacks as wasm://wasm/- instead of the fetch URL stored as code_file, so frames never link to the debug image and symbolication fails.

Solution

  • Match wasm://wasm/… frames to registered images via the wasm name section (moduleName parsed at registration)
  • If that section is missing or doesn’t match the stack label, guess from the basename in the synthetic filename (e.g. stack says demo.wasm, registered URL is demo_bg.wasm)
  • Accept a match only when all candidates share one debug_id (page + worker can register the same binary under different URLs)

How

  • At registration, read the wasm name custom section into internal moduleName (stripped before send)
  • In patchFrames(), when exact code_file lookup misses, compare the stack’s synthetic label to moduleName, then to registered URL basenames (including _bg.wasm → .wasm)

Limitations

d2anamaria and others added 10 commits August 31, 2026 23:37
- Patch `Response.prototype.arrayBuffer` and `bytes` to tag wasm buffers with `response.url` in a `WeakMap`
- Hook `WebAssembly.instantiate` and `compile` to use tagged URL to register module
- Skip registration when `instantiate` receives an already-compiled `WebAssembly.Module`
- Split `patchWebAssembly` into response, non-streaming, and streaming setup; guard non-streaming with `nonStreamingPatched`

- Add `patchWebAssembly.test.ts` for fetch → arrayBuffer → instantiate/compile
- Extend `webworker.test.ts` to restore patched globals and assert `instantiate` is hooked
- Chrome may emit `wasm://wasm/<file>-<hash>` for buffer-compiled modules
  (non-streaming / workers) instead of the fetch URL stored as `code_file`
- Exact URL lookup then fails, so frames stay unlinked (`unknown_image`,
  no `debug_meta.images`) even when the module is registered
- Fall back to a unique basename match on page + worker images; rewrite
  `filename` to `code_file` and set `addr_mode`
- Same `code_file` on page and worker counts as one module (worker crash
  while the page also loaded the wasm)
- Do not guess when two different URLs share a filename
- Bare `wasm://` frames still need `instruction_addr` from the JS parser
- Only handles `wasm://wasm/<file>-<hash>`; unnamed `wasm://` hashes and
  other browsers are unchanged
- wasm:// matching required a unique `code_file`, so the same binary
  registered under two URLs (page + worker, CDN vs origin) was skipped
- Uniqueness is now `debug_id` — Symbolicator keys off the build, not URL
- Still skip when two binaries share a filename but differ in `debug_id`;
  Chrome's wasm:// hash cannot tell them apart
- Parse wasm `name` custom section at registration into internal `moduleName`
- Extract `matchSyntheticWasmFilename` — prefer `moduleName`, then URL basename/`_bg` alias
- Accept synthetic matches only when all candidates share one `debug_id`
- Reject hash-only `wasm://wasm/<id>` labels (#23781)
- Strip `moduleName` via `toProtocolDebugImage` before attaching `debug_meta`
- Add `wasmNameSection`, `matchSyntheticWasmFilename`, and `registry` unit tests
- Add wasm module fixtures with `build_id` and optional `name` section
- Extend `processEvent` for bindgen `_bg` alias, ambiguous names, hash-only frames
- Extend `webworker` for worker images matched by `moduleName`
@d2anamaria
d2anamaria requested a review from a team as a code owner September 3, 2026 11:31
@d2anamaria
d2anamaria requested review from Lms24 and msonnb and removed request for a team September 3, 2026 11:31
@d2anamaria
d2anamaria marked this pull request as draft September 3, 2026 11:32
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.71 kB - -
@sentry/browser - with treeshaking flags 27.02 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.92 kB - -
@sentry/browser (incl. Tracing) 49.1 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 49.1 kB - -
@sentry/browser (incl. Tracing, Profiling) 52.01 kB - -
@sentry/browser (incl. Tracing, Replay) 88.58 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.88 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.26 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.21 kB - -
@sentry/browser (incl. Feedback) 46.2 kB - -
@sentry/browser (incl. sendFeedback) 33.78 kB - -
@sentry/browser (incl. FeedbackAsync) 38.87 kB - -
@sentry/browser (incl. Metrics) 29.68 kB - -
@sentry/browser (incl. Logs) 29.97 kB - -
@sentry/browser (incl. Metrics & Logs) 30.61 kB - -
@sentry/react 30.47 kB - -
@sentry/react (incl. Tracing) 51.3 kB - -
@sentry/vue 35.95 kB - -
@sentry/vue (incl. Tracing) 51.37 kB - -
@sentry/svelte 28.74 kB - -
CDN Bundle 30.45 kB - -
CDN Bundle (incl. Tracing) 49.64 kB - -
CDN Bundle (incl. Logs, Metrics) 32.69 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.56 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.28 kB - -
CDN Bundle (incl. Tracing, Replay) 87.13 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 89 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 93.06 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 95.01 kB - -
CDN Bundle - uncompressed 90.19 kB - -
CDN Bundle (incl. Tracing) - uncompressed 147.87 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.58 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.65 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.75 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.37 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.13 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.07 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.82 kB - -
@sentry/nextjs (client) 53.92 kB - -
@sentry/sveltekit (client) 49.53 kB - -
@sentry/core/server 40.96 kB - -
@sentry/core/browser 13.53 kB - -
@sentry/node 124.66 kB +0.02% +21 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.51 kB - -
@sentry/node - without tracing 88.5 kB +0.03% +23 B 🔺
@sentry/node - without channel injection 103.95 kB +0.03% +23 B 🔺
@sentry/aws-serverless 96.87 kB +0.03% +23 B 🔺
@sentry/cloudflare (withSentry) - minified 201.56 kB - -
@sentry/cloudflare (withSentry) 501.37 kB - -

View base workflow run

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.

2 participants