Skip to content

✨ [RUM-16985] Capture wasm module build_ids and enrich error events - #4920

Draft
ImaneLargou wants to merge 9 commits into
mainfrom
imane.largou/wasm-sdk-experiment
Draft

✨ [RUM-16985] Capture wasm module build_ids and enrich error events#4920
ImaneLargou wants to merge 9 commits into
mainfrom
imane.largou/wasm-sdk-experiment

Conversation

@ImaneLargou

@ImaneLargou ImaneLargou commented Jul 27, 2026

Copy link
Copy Markdown

Motivation

Browser WebAssembly runtime errors currently lack the module metadata required for WASM symbolication.

This change identifies errors containing WebAssembly stack frames and reports the loaded WASM module URL and build ID. This allows the error-processing pipeline to distinguish ordinary browser errors from errors that should use WASM/DWARF symbolication.

Related upstream schema change: DataDog/rum-events-format#427

Changes

  • Track WebAssembly modules loaded through:
    • WebAssembly.instantiate
    • WebAssembly.instantiateStreaming
    • WebAssembly.compile
    • WebAssembly.compileStreaming
  • Extract module build IDs from the build_id custom section, with external_debug_info as a fallback.
  • Detect WASM errors by checking the complete error stack for WASM-specific frames.
  • Report the following metadata on WASM errors:
    • error.source_type: "browser+wasm"
    • error.wasm_modules, containing the module URL and build ID
  • Add support to both RUM and Browser Logs.
  • Keep ordinary JavaScript errors unchanged. In particular, .js frames do not qualify an error as WASM.
  • Update the generated RUM event types from the corresponding rum-events-format schema change.

Test instructions

Run the relevant unit tests:

  • packages/browser-core/src/domain/wasmModules/wasmBinaryParser.spec.ts
  • packages/browser-core/src/domain/wasmModules/wasmModuleTracking.spec.ts
  • packages/browser-rum-core/src/domain/error/errorCollection.spec.ts
  • packages/browser-logs/src/domain/createErrorFieldFromRawError.spec.ts

Run the E2E scenario:

yarn test:e2e -g "send WebAssembly runtime errors with module metadata"

The E2E test loads a real .wasm module using WebAssembly.instantiateStreaming, triggers a runtime error, and verifies that both RUM and Logs events contain:

  {
    "source_type": "browser+wasm",
    "wasm_modules": [
      {
        "url": "<test module URL>",
        "build_id": "abcd"
      }
    ]
  }

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

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@datadog-official

datadog-official Bot commented Jul 27, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 79.55%
Overall Coverage: 77.24% (+0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 420fdee | 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
@ImaneLargou
ImaneLargou marked this pull request as ready for review August 11, 2026 09:47
@ImaneLargou
ImaneLargou requested a review from a team as a code owner August 11, 2026 09:47
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 11, 2026

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 180.44 KiB 183.27 KiB +2.83 KiB +1.57%
Rum Profiler 8.43 KiB 8.43 KiB 0 B 0.00%
Rum Recorder 21.12 KiB 21.12 KiB 0 B 0.00%
Logs 57.04 KiB 59.78 KiB +2.74 KiB +4.81%
Rum Salesforce N/A 141.21 KiB N/A N/A N/A
Rum Slim 138.47 KiB 141.24 KiB +2.77 KiB +2.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%
Rum Shopify N/A 202.75 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.43 KiB N/A N/A N/A
Rum-shopify Recorder N/A 3.72 KiB N/A N/A N/A

@ImaneLargou
ImaneLargou marked this pull request as draft August 11, 2026 10:10
@ImaneLargou

Copy link
Copy Markdown
Author

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

@ImaneLargou ImaneLargou changed the title [WASM] Capture wasm module build_ids and enrich error events ✨ [RUM-16985] Capture wasm module build_ids and enrich error events Aug 11, 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