Skip to content

[WASM] Capture wasm module build_ids and enrich error events - #4920

Draft
ImaneLargou wants to merge 1 commit into
mainfrom
imane.largou/wasm-sdk-experiment
Draft

[WASM] Capture wasm module build_ids and enrich error events#4920
ImaneLargou wants to merge 1 commit into
mainfrom
imane.largou/wasm-sdk-experiment

Conversation

@ImaneLargou

Copy link
Copy Markdown

Intercepts WebAssembly.instantiate / instantiateStreaming at SDK script-load time to record (url, build_id) per loaded module, including lazily-loaded modules. On error capture, attaches error.wasm_modules[] and sets source_type='browser+wasm' so the backend can dispatch wasm symbolication.

  • New wasmModules/wasmModuleTracking.ts: hooks all four WebAssembly entry points; reads build_id via a minimal custom-section parser; registry stays live for lazy module loads
  • New wasmModules/wasmBinaryParser.ts: walks wasm binary sections, extracts build_id custom section or falls back to external_debug_info
  • errorCollection: populates error.wasm_modules[] and flips source_type to 'browser+wasm' when any module is registered
  • rawRumEvent.types: adds wasm_modules?: Array<{url, build_id}> to RawRumErrorEvent
  • main.ts: installs tracking synchronously at script-load time to close the race window before DD_RUM.init()'s deferred microtask

Motivation

Changes

Test instructions

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

Intercepts WebAssembly.instantiate / instantiateStreaming at SDK
script-load time to record (url, build_id) per loaded module, including
lazily-loaded modules. On error capture, attaches error.wasm_modules[]
and sets source_type='browser+wasm' so the backend can dispatch wasm
symbolication.

- New wasmModules/wasmModuleTracking.ts: hooks all four WebAssembly
  entry points; reads build_id via a minimal custom-section parser;
  registry stays live for lazy module loads
- New wasmModules/wasmBinaryParser.ts: walks wasm binary sections,
  extracts build_id custom section or falls back to external_debug_info
- errorCollection: populates error.wasm_modules[] and flips source_type
  to 'browser+wasm' when any module is registered
- rawRumEvent.types: adds wasm_modules?: Array<{url, build_id}> to
  RawRumErrorEvent
- main.ts: installs tracking synchronously at script-load time to close
  the race window before DD_RUM.init()'s deferred microtask

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@datadog-official

datadog-official Bot commented Jul 27, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 8 Pipeline jobs failed

DataDog/browser-sdk | e2e: [firefox]   View in Datadog   GitLab

🧪 1 Test failed

debugger › omit trace correlation data when no active span is available › npm from debugger.scenario.ts   View in Datadog
expect(received).toHaveLength(expected)

[firefox] › debugger.scenario.ts:286:13 › debugger › omit trace correlation data when no active span is available › npm 

    Error: expect(received).toHaveLength(expected)

    Expected length: 0
    Received length: 1
    Received array:  [{&#34;level&#34;: &#34;error&#34;, &#34;message&#34;: &#34;&#39;get closed&#39; called on an object that does not implement interface MediaKeySession.&#34;, &#34;source&#34;: &#34;console&#34;, &#34;timestamp&#34;: 1785154887055}]

...

DataDog/browser-sdk | unit   View in Datadog   GitLab

🧪 5 Tests failed

error collection addError notifies a raw rum error event from an error instance from Chrome Headless 149.0.0.0 (Linux 0.0.0)   View in Datadog
Expected $.rawRumEvent.error not to have properties
    wasm_modules: undefined
Error: Expected $.rawRumEvent.error not to have properties
    wasm_modules: undefined
    at &lt;Jasmine&gt;
    at UserContext.&lt;anonymous&gt; (/go/src/github.com/DataDog/browser-sdk/packages/browser-rum-core/src/domain/error/errorCollection.spec.ts:76:33 &lt;- /tmp/_karma_webpack_627606/commons.js:396889:41)
    at &lt;Jasmine&gt;
error collection addError notifies a raw rum error event from an error subclass via prototype from Chrome Headless 149.0.0.0 (Linux 0.0.0)   View in Datadog
Expected $.rawRumEvent.error not to have properties
    wasm_modules: undefined
Error: Expected $.rawRumEvent.error not to have properties
    wasm_modules: undefined
    at &lt;Jasmine&gt;
    at UserContext.&lt;anonymous&gt; (/go/src/github.com/DataDog/browser-sdk/packages/browser-rum-core/src/domain/error/errorCollection.spec.ts:76:33 &lt;- /tmp/_karma_webpack_627606/commons.js:396889:41)
    at &lt;Jasmine&gt;
View all failed tests

DataDog/browser-sdk | build-and-lint   View in Datadog   GitLab

View all 8 failed jobs.

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2048314 | Docs | Datadog PR Page | Give us feedback!

@ImaneLargou ImaneLargou changed the title ✨ [RUM-WASM] Capture wasm module build_ids and enrich error events [WASM] Capture wasm module build_ids and enrich error events Jul 27, 2026
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.

1 participant