Repository navigation
🐛 [RUM-20348] Handle direct onunhandledrejection calls without an event - #5312
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Bundles Sizes Evolution
|
There was a problem hiding this comment.
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.
🤖 Bits Code Review · Commit 01704e1
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 4332633 | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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.
🤖 Bits Code Review · Commit 4332633
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 globalon*handlers directly with no argument, for examplewindow.onunhandledrejection(). Ouronunhandledrejectioninstrumentation reade.reasonwithout 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
instrumentUnhandledRejectionreadse?.reason, so a direct call without an event no longer throws. Like any rejection with an empty reason, it is reported as anEmpty reasonerror, and the original handler is still called.Empty reasonand 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; anEmpty reasonRUM error is collected instead. Real unhandled rejections (Promise.reject(new Error('x'))) are still collected.Checklist