Skip to content

🐛 [RUM-20348] Handle direct onunhandledrejection calls without an event - #5312

Merged
thomas-lebeau merged 2 commits into
mainfrom
thomas.lebeau/RUM-20348-unhandledrejection-no-event
Nov 23, 2026
Merged

thomas-lebeau merged 2 commits into
mainfrom
thomas.lebeau/RUM-20348-unhandledrejection-no-event

Conversation

@thomas-lebeau

@thomas-lebeau thomas-lebeau commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Telemetry error Cannot read properties of undefined (reading 'reason') (RUM-20348). It recently came in bursts of thousands of events from a single page, enough to trigger the telemetry monitors. Almost all of it comes from security scanners. These scanners call the global on* handlers directly with no argument, for example window.onunhandledrejection(). Our onunhandledrejection instrumentation read e.reason without checking that an event was passed, so it threw.

The page's own handler still ran, so pages saw no change in behavior. The only effect was SDK telemetry noise.

Changes

  • instrumentUnhandledRejection reads e?.reason, so a direct call without an event no longer throws. Like any rejection with an empty reason, it is reported as an Empty reason error, and the original handler is still called.
  • Adds a unit test: a direct call with no event is reported as Empty reason and sends no telemetry error. Without the fix, this test fails.

Test instructions

On a page with RUM initialized, run window.onunhandledrejection() in the console. Before this change, the SDK sends a telemetry error (reading 'reason'). After it, no telemetry error is sent; an Empty reason RUM error is collected instead. Real unhandled rejections (Promise.reject(new Error('x'))) are still collected.

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

@thomas-lebeau
thomas-lebeau requested a review from a team as a code owner November 21, 2026 11:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 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-23T06:28:45.885433Z 4332633 New commits
🔒 Security Review ✅ Completed 2026-11-23T06:30:20.036989Z 4332633 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.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 193.94 KiB 193.94 KiB +1 B +0.00% ✅
Rum 193.92 KiB 193.92 KiB +1 B +0.00% ✅
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.80 KiB 32.80 KiB 0 B 0.00% ✅
Rum Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Logs 60.25 KiB 60.25 KiB +1 B +0.00% ✅
Rum Slim 149.73 KiB 149.73 KiB +1 B +0.00% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 225.46 KiB 225.46 KiB +1 B +0.00% ✅
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% ✅

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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

Calls to window.onunhandledrejection() without an event are ignored before accessing reason, while normal rejection processing and calls to the original handler are preserved.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 01704e1

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 0.00%
• Overall Coverage: 77.89% (-0.01%)

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

@thomas-lebeau thomas-lebeau changed the title 🐛 [RUM-20348] Ignore direct onunhandledrejection calls without an event 🐛 [RUM-20348] Handle direct onunhandledrejection calls without an event Nov 23, 2026

@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: 433263397b

ℹ️ 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".

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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

The PR prevents missing-event telemetry exceptions and preserves normal rejection handling. One issue remains: the latest revision turns eventless calls into false “Empty reason” RUM errors and forwarded error logs; restoring the event guard and updating the test would avoid customer-facing error noise.

Open Bits AI session

🤖 Bits Code Review · Commit 4332633

@thomas-lebeau
thomas-lebeau merged commit 989dacc into main Nov 23, 2026
34 checks passed
@thomas-lebeau
thomas-lebeau deleted the thomas.lebeau/RUM-20348-unhandledrejection-no-event branch November 23, 2026 08:08
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants