Skip to content

✨ [DEBUG-6444] Capture Exception Replay snapshots for RUM errors - #5196

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 22 commits into
mainfrom
watson/exception-replay-method-probes
Nov 19, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 22 commits into
mainfrom
watson/exception-replay-method-probes

Conversation

@watson

@watson watson commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

DEBUG-6444

Exception Replay shows the arguments a function had when an error passed through it, on the error's stack frames in Error Tracking. Backend errors get it from the tracers, but browser errors have nothing like it. This brings it to browser errors reported by RUM, using the Live Debugger's build-time instrumentation. This first version captures arguments and this only, not local variables.

Changes

  • Capture: code built with the Live Debugger build plugin's new exceptionReplay option calls $dd_catch for every exception that leaves an instrumented function. The SDK captures the arguments and this of the three innermost frames as the exception is thrown, and keeps them with the error in a WeakMap. Errors that RUM never reports are garbage collected with their captures, and nothing is sent for them.
  • Linking to the RUM error: DD_DEBUGGER.init() adds a RUM plugin to the RUM Browser SDK with DD_RUM.addPlugin() (✨ [DEBUG-6444] Let SDKs add RUM plugins after init with addPlugin() #5220), once RUM has loaded, so customers don't change their RUM configuration, and the Live Debugger SDK can load after RUM is initialized. The plugin adds error.debug_info_captured: "true" and _dd.exception_replay (the exception ID, plus the stack index and snapshot ID of each captured frame) to the RUM error event while it's assembled. Each snapshot carries exceptionId, so the UI treats it as an Exception Replay snapshot.
  • Only for errors RUM sends: the plugin holds the snapshots until RUM collects the error event, after beforeSend and the event rate limits. An error that either of them drops sends no snapshots, and doesn't start the one-hour limit for its fingerprint.
  • New RUM plugin hook (RUM core change): RumPluginOnInitOptions.registerEventCollectedHook registers a callback that runs once an event has passed beforeSend and the rate limits, right before it's sent. It's backed by a new eventCollected hook in hooks.ts, triggered in assembly.ts. A new isTrackingConsentGranted() option tells plugins whether tracking consent is granted, including consent set with setTrackingConsent() before init(). Exception Replay only captures while it is granted, and after RUM starts, also only while RUM tracks the session. It checks both before each frame, because consent can be withdrawn while an exception propagates, and the event bridge's session stays tracked after consent is withdrawn. An error that RUM reports while either is false has its captures discarded, so they're never sent. With an older RUM SDK that lacks either option or addPlugin(), Exception Replay warns and stays off.
  • Frame indexes: the SDK finds each captured frame's position in error.stack by lining up the call stack taken inside $dd_catch with the error's stack, as parsed by computeStackTrace. When both frames have a function name, the names must match, as two functions called from the same call site have the same callers. Error Tracking attaches snapshots to frames by that position.
  • Redaction: Exception Replay captures redact values with sensitive names, using the tracers' list. Live Debugger probe snapshots are unchanged.
  • Limits: at most 10 new exceptions captured per second, and at most 25 ms per second of capture time on average. Each frame's 10 ms deadline is also capped by the remaining budget, and time spent beyond it is carried over, so capturing pauses until it's made up. An error with the same type and innermost function is reported with snapshots at most once an hour. These limits are separate from the probes' maxSnapshotsPerSecondGlobally, so neither feature can use up the other's. Exceptions thrown while a frame is captured, such as by a getter on an argument that runs instrumented code, are ignored.
  • Who's affected: only applications that are built with exceptionReplay, and initialize both the RUM Browser SDK and the Live Debugger SDK. $dd_catch is only defined once RUM has initialized the plugin and the Live Debugger SDK is initialized. Nothing is captured in sessions that RUM doesn't track.
  • No runtime dependency on RUM: the plugin's types are written out in browser-debugger. Specs check at compile time that it's still assignable to RumPlugin, and that the RUM public API still has the onReady() and addPlugin() it uses. browser-rum-core is only a devDependency, because declaring it as a dependency broke yarn build:apps.

This change was written with an AI agent. Please look closely at the frame-index matching in exceptionReplay.ts, the RUM plugin's types, and the new eventCollected hook, which the RUM team should review.

Schema: @datadog/rum-events-format is pinned to the merge commit of DataDog/rum-events-format#458, which adds the new fields.

Builds on #5220, now merged, which adds addPlugin().

Test instructions

  • Unit tests: yarn test:unit --spec packages/browser-debugger/src/domain/exceptionReplay.spec.ts. The plugin, redaction and capture specs sit next to it.
  • End to end: yarn test:e2e -g "Exception Replay". One test checks the snapshots are linked to the RUM error event, the other that an error dropped by beforeSend sends none. The test page uses hand-written code equivalent to what the build plugin generates, so it doesn't need a build-plugins release. Both pass in Chromium, Firefox and WebKit.

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

Related PRs

Reviewed with sol-loop: 4 rounds with gpt-6.2-sol on xhigh. Sol verdict: approved

Created with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code.

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 77.54%
• Overall Coverage: 77.92% (-0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 04feaab | Docs | View more details | Give us feedback!

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 193.61 KiB 193.91 KiB +304 B +0.15% ✅
Rum 193.59 KiB 193.89 KiB +304 B +0.15% ✅
Rum Salesforce Profiler 8.01 KiB 8.01 KiB 0 B 0.00% ✅
Rum Profiler 8.01 KiB 8.01 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.62 KiB 32.62 KiB 0 B 0.00% ✅
Rum Recorder 32.62 KiB 32.62 KiB 0 B 0.00% ✅
Logs 60.25 KiB 60.25 KiB 0 B 0.00% ✅
Rum Slim 149.41 KiB 149.71 KiB +301 B +0.20% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 224.96 KiB 225.25 KiB +304 B +0.13% ✅
Rum Shopify Profiler 8.00 KiB 8.00 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T19:15:29.368506Z 04feaab New commits
🔒 Security Review ✅ Completed 2026-11-19T19:20:42.003534Z 04feaab New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@watson
watson marked this pull request as draft October 31, 2026 15:24
@watson
watson removed request for a team October 31, 2026 15:24

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

Exception Replay can attach arguments to unrelated async stack frames, omit valid captures, and upload sensitive symbol-property values without redaction. Serialization failures and retries of previously dropped errors can also bypass capture limits.

Open Bits AI session

🤖 Bits Code Review · Commit d17501a

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d17501a1aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@watson
watson marked this pull request as ready for review November 3, 2026 11:55

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

Snapshot links can point to the wrong frame in single-line async bundles or to nonexistent frames when a thrown plain object is reported through RUM. Both defects have localized fixes.

Open Bits AI session

🤖 Bits Code Review · Commit 5baae08

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8db607da74

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/browser-debugger/README.md Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9cbf27e05e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@watson
watson changed the base branch from main to watson/DEBUG-6444/rum-add-plugin November 3, 2026 12:58

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

Exception Replay can retain arguments captured while effective RUM consent is denied and send them when the same Error is reported after consent is granted. Anonymous async catches can also attach snapshots to unrelated stack frames.

Open Bits AI session

🤖 Bits Code Review · Commit f72c087

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

for (const plugin of pluginsAddedBeforeInit.splice(0)) {
startAddedPlugin(plugin, pluginOnInitOptions)

P2 Badge Defer added plugins until initialization is accepted

issue: When a plugin supplied to init() returns or resolves to false, this loop still initializes plugins queued through addPlugin() before shouldContinue is checked. In the normal debugger-before-RUM load order, that starts the Exception Replay plugin and installs $dd_catch; because RUM never calls onRumStart, its pre-start predicate keeps capturing arguments indefinitely even though RUM will never report them. The same problem occurs when configuration validation later rejects the init, and a subsequent valid init() cannot reinitialize the already-drained plugin with the new configuration.


if (isThenable(onInitResult)) {
onInitResult.then(() => callAddedPluginOnRumStartOnceStarted(plugin), monitorError)
} else {
callAddedPluginOnRumStartOnceStarted(plugin)

P2 Badge Skip onRumStart when an added plugin returns false

issue: When an added plugin's onInit returns false or resolves to false, these branches discard that result and still schedule onRumStart. Although an added plugin must not abort RUM itself, false is the plugin contract's signal that initialization should not continue; calling onRumStart can therefore activate a plugin that detected an unsupported setup or only partially initialized. Treat false like a failed added-plugin initialization and skip that plugin's onRumStart while allowing RUM to continue.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfa04bba24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@watson

watson commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

Note

🤖 Claude Opus 5.5 responding on behalf of Thomas Watson

Replying to the Codex review above: both findings are fixed in #5220 (26f1779) and merged here in aa5ab4d.

  • Defer added plugins until initialization is accepted: plugins added with addPlugin() now start only once the init() plugins have let init() continue. If one of them aborts init(), the added plugins stay queued for a later init(). A configuration that fails validation doesn't stop them, but it doesn't stop the init() plugins either, since both run their onInit before validation.
  • Skip onRumStart when an added plugin returns false: an added plugin whose onInit returns or resolves to false no longer gets onRumStart, and RUM still continues.

@watson
watson added this pull request to stack #5229 November 3, 2026 14:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df1a3640ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@watson
watson force-pushed the watson/exception-replay-method-probes branch from 4d7f7cc to c1df8a8 Compare November 19, 2026 11:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1df8a82d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

watson and others added 9 commits November 19, 2026 12:42
A function without callers was matched to a frame of the same script
that came earlier in the file whenever one of the two had no function
name. An anonymous function that caught an error created by a named
function of the same script was then linked to that function's frame.

A frame with a name and one without are now from different functions.
Two unnamed functions of the same script can still be mistaken for each
other.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ption Replay spec

The async callee spec failed on Chrome 80 and Edge 80 on BrowserStack.
V8 8.0 only adds async frames to a stack when the function resumed from
an `await` that fulfilled. V8 8.1 (Chrome 81) also handles an `await`
that rejected. `asyncCaller` resumes from a rejected `await`, so on
Chromium 80 its stack has no callers and it gets no snapshot. The probe
resumed from a fulfilled `await`, so it still reported that the browser
shows the caller.

Resume the probe from a rejected `await`, like the scenario it guards.

Environment: Datadog workspace

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…urns DISCARDED

The `eventCollected` hook reused the assemble hooks' `Hook` type. Its
`register()` accepted callbacks that return `DISCARDED`, and `trigger()`
stopped at the first one, while RUM still sent the event. A plugin
registered after one that returned `DISCARDED` never saw the event. For
Exception Replay, the error event would link to snapshots that were
never sent.

Give the hook its own type, backed by an `Observable`, that calls every
callback and ignores what they return.

Environment: Datadog workspace

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…frame matching

After an `await`, Chrome shows an anonymous async caller as `at async
<url>:line:col`, which `computeStackTrace` parses as a function named
`async`. `ASYNC_FRAME_PREFIX` required a space or `*` after `async`, so
that frame wasn't treated as an async frame, and its `await` column was
compared against the call's column in the error's stack. The function it
called then got no snapshot, as in an `async () => { await f() }`
callback.

Unit tests now run with Vitest, where the spec's own test callback is
such an anonymous async caller, which surfaced this in the "awaiting a
callee that throws before its first await" spec.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y frame

Only the first frame of an exception checked whether RUM tracks the
session. Frames captured later, as the exception propagated or was
rethrown after tracking consent was withdrawn, were still captured.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Once RUM started, Exception Replay only checked that RUM had a session.
The event bridge's session stub stays tracked when tracking consent is
withdrawn, so WebViews kept capturing. Consent is now checked too.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…frames

A function with callers was matched to an error stack frame by URL and
callers only. Two functions called from the same call site have the same
callers, so a snapshot could be linked to the frame of another function
in the same script. Their names now have to match when both frames have
one.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cking

The event bridge's session stays tracked when tracking consent is
withdrawn, so RUM can still report an error captured before. Its
snapshots, which the debugger transport sends over HTTP rather than
through the bridge, were still linked and sent. When RUM assembles or
collects the error event while tracking is off, the error's captures
are now discarded, so they're never sent, even if the error is reported
again once tracking resumes.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…R head

DataDog/rum-events-format#458 now includes master, so the generated
types match both its Exception Replay fields and the newer master fields
main uses. The regenerated types are unchanged.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot force-pushed the watson/exception-replay-method-probes branch from 57ef0b1 to 04c70a0 Compare November 19, 2026 12:42
…Replay frame

Capturing a frame reads its arguments and `this`, whose getters can run
instrumented code. If that code threw, $dd_catch re-entered before the
current frame was stored or its time charged, so nested captures could
get past the three-frame limit and charge overlapping time to the
capture budget. Such exceptions come from the capture itself, so
$dd_catch now ignores them.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: FAIL

Exception Replay can recursively capture a reused error through an instrumented getter, bypassing its frame and time limits and potentially exhausting the stack.

Open Bits AI session

🤖 Bits Code Review · Commit 04c70a0

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

Exception Replay captures function arguments and receivers for RUM errors, redacts sensitive names, limits capture work, and sends snapshots only after RUM filtering. The new reentrancy guard fixes the previously reported getter recursion and resets in finally; no findings remain open.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 950b92d

… merge commit

DataDog/rum-events-format#458 is merged. The regenerated types are
unchanged.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@watson
watson requested review from a team November 19, 2026 14:48
Its only consumer, the Exception Replay plugin, reads the event type and
domain context only.

Environment: Datadog workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@watson

watson commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-11-19 19:33:54 UTC ℹ️ Start processing command /merge
Use /merge -c to cancel this operation!


2026-11-19 19:33:58 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 20m (p90).

Use /merge -c to cancel this operation!


⏳ Building merge commit 5a6586c41d in pipeline 6285655970943912769...

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 8b883cf into main Nov 19, 2026
32 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the watson/exception-replay-method-probes branch November 19, 2026 19:51
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants