Repository navigation
Report errors from another frame as themselves, and leave out Cloudflare's own - #2926
Merged
Merged
Conversation
…are's own OpenBot Cloud's Cloudflare zone injects a script into every page that makes a hidden same-origin frame and writes its loader into it with innerHTML. The frame inherits the page's Trusted Types rule but not OpenBot's policies, so Chrome and Safari refuse the write, and the refusal reaches the window as an uncaught error made in the frame. It isn't instanceof this window's Error, so the reporter sent "A object was thrown": 575 junk reports since 3 December, nearly one per page load, hiding real errors. - An error is recognised whichever frame made it: Error.isError where the browser has it, then its built-in tag ([object Error], DOMException and the like), then instanceof, as Sentry, PostHog's SDK and Bugsnag do. Its real name, message and stack are sent. - Cloudflare's own errors are left out, as Sentry's denyUrls and third-party filter do: one thrown in a file under /cdn-cgi/, and the Trusted Types refusal made in another frame whose whole stack is in the page's own markup, on a page that carries Cloudflare's loader. OpenBot's own Trusted Types refusals, thrown from its files in its window or a frame of its own, are still reported. Trusted Types and the CSP are unchanged. A real-browser test in Chromium and WebKit holds all three, against Cloudflare's script as OpenBot Cloud's page carries it.
davidmckayv
requested review from
MikeRyanDev,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
December 4, 2026 07:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
On OpenBot Cloud, nearly every page load sent an error report reading "A object was thrown": 575 of them since 22:10Z on 3 December. They hid real errors.
The cause, read live from OpenBot Cloud's sign-in page in Chrome and in WebKit:
/cdn-cgi/challenge-platform/scripts/jsd/main.js) into it withinnerHTML.index.html) but none of OpenBot's policies (app/src/lib/trusted-types.ts). So the browser refuses the write, and the refusal reaches the window as an uncaught error. Chrome words itTypeError: This document requires 'TrustedHTML' assignment. at HTMLDocument.c (https://my.open.bot/sign:291:154), and WebKit asTypeError: This assignment requires a TrustedHTML,c@https://my.open.bot/sign:291:145.instanceofthis window'sError. The reporter (app/src/lib/error-reporting.tsx) only knew this window'sError, so it sent the placeholder.The fix
Error.isErrorwhere it has one, then the built-in tag ([object Error],[object DOMException],[object Exception],[object DOMError],[object WebAssembly.Exception]), theninstanceof. That way an error from any same-origin frame is reported with its real name, message and stack./cdn-cgi/, judged by where the browser says it was thrown, or else by the top line of its stack;/cdn-cgi/challenge-platform/loader.How the leaders do it
instanceofsecond.isErrorswitches onObject.prototype.toString(Error, Exception, DOMException, WebAssembly.Exception) and only then usesinstanceof Error(sentry-javascriptis.ts).type-utils.ts).iserrorpackage, the same check (bugsnag-jsiserror.js).instanceof Error || toString === '[object Error]'(browser-sdkisError.ts).Error.isErrorfirst where the browser has it. It answers the same question, and only adds a check.denyUrls), and itsthirdPartyErrorFilterIntegrationdrops errors whose frames aren't in the app's own files (Sentry filtering docs).beforeSend(Datadog: enrich and control RUM data).onErrorcallback (Bugsnag browser FAQ)./cdn-cgi/, and drop an error whose whole stack is outside OpenBot's files. It narrows the second rule to Cloudflare's Trusted Types refusal, so nothing of OpenBot's is dropped with it.Tests
app/tests/app-error-reporting-browser.test.tsis a real-browser test in Chromium and WebKit, with the app's own Trusted Types<meta>and Cloudflare's script as OpenBot Cloud's page carries it. It is added to theapp (real browser, WebKit)list, which runs both engines./cdn-cgi/are not reported.TrustedScript) and in a frame of its own (TrustedHTML, a refusal made in another frame like Cloudflare's).All four tests (each of the three cases above, in both engines) fail without the fix and pass with it:
app/tests/app-error-reporting.test.tsxalso checks how a stack's addresses are read, against the exact Chrome and WebKit stacks taken from OpenBot Cloud.Changelog
Web app.