Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

Drop non-actionable client-error noise at both ends

nirholas1199f1b0d4a1
diff --git a/api/client-errors.js b/api/client-errors.js
index 4c6bb7494..200598b14 100644
--- a/api/client-errors.js
+++ b/api/client-errors.js
@@ -56,6 +56,36 @@ function isDevOriginPage(page) {
);
}
+// Bridge globals that mobile in-app browsers and browser extensions inject into
+// every page they wrap (Twitter/X, Chrome iOS, Firefox iOS, the Bing app, …).
+// Our code never references any of them, so a "Can't find variable: currentInset"
+// is the injected bridge script failing in the page context — not a three.ws
+// fault. Documented webview/extension globals only, matched as whole words.
+const INJECTED_GLOBALS =
+ /\b(currentInset|gCrWeb|__gCrWeb|__firefox__|_AutofillCallbackHandler|instantSearchSDKJSBridgeClearHighlight|webkitStorageInfo|bannerNight|ceCurrentVideo|isHighlightingEnabled|zaloJSV2|MyAppGetLinkProperties)\b/;
+
+// Errors that originate outside our code and are never actionable from a deploy.
+// Dropping them at the boundary keeps the prod error logs, Sentry, and ops paging
+// focused on genuine first-party faults. Clients running a freshly-cached
+// error-reporter.js already filter these locally; this is the server-side
+// backstop for the long tail of clients holding an older cached reporter.
+function isNonActionableNoise(event) {
+ if (event.type !== 'error' && event.type !== 'unhandledrejection') return false;
+ const msg = event.message || '';
+ // Cross-origin "Script error." — the browser strips every detail (stack,
+ // file, line) from an exception thrown by a script served without CORS
+ // headers, leaving nothing to act on.
+ if (/^Script error\.?$/.test(msg)) return true;
+ // AbortError — a deliberate fetch/navigation cancellation (AbortController
+ // or a superseded in-flight request), not a failure.
+ if (event.name === 'AbortError' || /\bfetch is aborted\b|\bthe operation was aborted\b/i.test(msg)) {
+ return true;
+ }
+ // A ReferenceError naming a known injected bridge global — their script, not ours.
+ if (/can't find variable:|is not defined/i.test(msg) && INJECTED_GLOBALS.test(msg)) return true;
+ return false;
+}
+
// Map both CSP report wire formats onto our event shape:
// report-uri: { "csp-report": { "violated-directive", "blocked-uri", ... } }
// report-to: [ { type: "csp-violation", body: { effectiveDirective, blockedURL, ... } } ]
@@ -139,7 +169,14 @@ export default wrap(async (req, res) => {
ip,
};
+ let dropped = 0;
for (const event of events) {
+ // Third-party / injected / cancellation noise never reaches the logs,
+ // Sentry, or the ops channel — see isNonActionableNoise.
+ if (isNonActionableNoise(event)) {
+ dropped++;
+ continue;
+ }
// Resource load failures (a CDN blip, an offline mobile network, a
// third-party embed like Cloudflare Turnstile being briefly unreachable)
// and CSP reports (browser extensions trip these constantly) are client-side
@@ -174,5 +211,5 @@ export default wrap(async (req, res) => {
}
}
- return json(res, 202, { received: events.length });
+ return json(res, 202, { received: events.length - dropped, dropped });
});
diff --git a/public/error-reporter.js b/public/error-reporter.js
index 35998a82b..9f83ca0f3 100644
--- a/public/error-reporter.js
+++ b/public/error-reporter.js
@@ -88,6 +88,14 @@
// only ever occur off a dev build; on the off chance a preview surfaces one,
// it is tooling noise, never a product fault.
const IGNORED_DEV_TOOLING = /\/@vite\/client|\/@react-refresh|vite\/dist\/client/;
+ // Bridge globals that mobile in-app browsers and browser extensions inject
+ // into every page they wrap (Twitter/X, Chrome iOS, Firefox iOS, the Bing
+ // app, …). Our code references none of them, so a "Can't find variable:
+ // currentInset" is their injected script failing in the page context, not a
+ // three.ws fault. Documented webview/extension globals only, whole-word.
+ const INJECTED_GLOBALS =
+ /\b(currentInset|gCrWeb|__gCrWeb|__firefox__|_AutofillCallbackHandler|instantSearchSDKJSBridgeClearHighlight|webkitStorageInfo|bannerNight|ceCurrentVideo|isHighlightingEnabled|zaloJSV2|MyAppGetLinkProperties)\b/;
+ const INJECTED_GLOBAL_ERROR = /can't find variable:|is not defined/i;
const truncate = (value, max) => {
if (typeof value !== 'string' || !value) return undefined;
@@ -165,6 +173,26 @@
return true;
}
if (report.message && IGNORED_MESSAGES.includes(report.message)) return true;
+ // Cross-origin "Script error." — the browser strips stack/file/line from an
+ // exception thrown by a script served without CORS headers, so there is
+ // nothing actionable in it. (Same-origin faults always carry a real message.)
+ if (report.message && /^Script error\.?$/.test(report.message)) return true;
+ // AbortError — a deliberate fetch/navigation cancellation (AbortController
+ // or a superseded in-flight request), never a fault.
+ if (
+ report.name === 'AbortError' ||
+ (report.message && /\bfetch is aborted\b|\bthe operation was aborted\b/i.test(report.message))
+ ) {
+ return true;
+ }
+ // A ReferenceError naming a known injected webview/extension bridge global.
+ if (
+ report.message &&
+ INJECTED_GLOBAL_ERROR.test(report.message) &&
+ INJECTED_GLOBALS.test(report.message)
+ ) {
+ return true;
+ }
// Internal failures of a third-party CDN library (identified by the script
// they originate from, via either the error's source or its stack) are not
// actionable from our code.
diff --git a/tests/api/client-errors.test.js b/tests/api/client-errors.test.js
index c923c74ae..3e1c8138c 100644
--- a/tests/api/client-errors.test.js
+++ b/tests/api/client-errors.test.js
@@ -145,6 +145,70 @@ describe('api/client-errors', () => {
expect(logged.ip).toBe('203.0.113.7');
});
+ describe('non-actionable noise filter', () => {
+ const cases = [
+ ['cross-origin "Script error."', { type: 'error', message: 'Script error.' }],
+ ['cross-origin "Script error" (no period)', { type: 'error', message: 'Script error' }],
+ [
+ 'AbortError by name',
+ { type: 'unhandledrejection', name: 'AbortError', message: 'Fetch is aborted' },
+ ],
+ [
+ 'aborted by message',
+ { type: 'unhandledrejection', message: 'The operation was aborted' },
+ ],
+ [
+ 'injected webview global (Safari)',
+ { type: 'error', name: 'ReferenceError', message: "Can't find variable: currentInset" },
+ ],
+ [
+ 'injected webview global (Chrome/FF)',
+ { type: 'error', name: 'ReferenceError', message: 'gCrWeb is not defined' },
+ ],
+ ];
+ for (const [label, event] of cases) {
+ it(`drops ${label} — no log, no Sentry, no page`, async () => {
+ const { status, body } = await invoke({
+ body: { page: 'https://three.ws/walk', events: [{ ts: 1, ...event }] },
+ });
+ expect(status).toBe(202);
+ expect(body.received).toBe(0);
+ expect(body.dropped).toBe(1);
+ expect(consoleError.mock.calls.filter(([tag]) => tag === '[client-error]')).toHaveLength(0);
+ expect(captureException).not.toHaveBeenCalled();
+ expect(sendOpsAlert).not.toHaveBeenCalled();
+ });
+ }
+
+ it('still reports a real ReferenceError that names one of our own variables', async () => {
+ const { body } = await invoke({
+ body: {
+ page: 'https://three.ws/walk',
+ events: [{ type: 'error', name: 'ReferenceError', message: 'renderScene is not defined', ts: 1 }],
+ },
+ });
+ expect(body.received).toBe(1);
+ expect(body.dropped).toBe(0);
+ expect(captureException).toHaveBeenCalledTimes(1);
+ });
+
+ it('drops only the noise events in a mixed batch', async () => {
+ const { body } = await invoke({
+ body: {
+ page: 'https://three.ws/walk',
+ events: [
+ errorEvent(),
+ { type: 'error', message: 'Script error.', ts: 1 },
+ { type: 'unhandledrejection', name: 'AbortError', message: 'Fetch is aborted', ts: 2 },
+ ],
+ },
+ });
+ expect(body.received).toBe(1);
+ expect(body.dropped).toBe(2);
+ expect(consoleError.mock.calls.filter(([tag]) => tag === '[client-error]')).toHaveLength(1);
+ });
+ });
+
it('forwards JS errors to Sentry with the client stack, but not resource events', async () => {
await invoke({
body: {