Skip to content

Write HTML. Render video. Built for agents.

fix(studio): stop counting extension-leaked AbortError rejections as errors (#4209)

Vance Ingalls83624d193e6b
diff --git a/packages/studio/src/main.tsx b/packages/studio/src/main.tsx
index 9d69aacb66..9f46b23fd4 100644
--- a/packages/studio/src/main.tsx
+++ b/packages/studio/src/main.tsx
@@ -65,6 +65,10 @@ window.addEventListener("error", (event) => {
});
let filteredAssetErrorCount = 0;
+let filteredAbortCount = 0;
+// Bounded so a hostile extension cannot grow it; a novel abort message still surfaces once.
+const seenAbortMessages = new Set<string>();
+const MAX_SEEN_ABORT_MESSAGES = 20;
// fallow-ignore-next-line complexity
window.addEventListener("unhandledrejection", (event) => {
@@ -80,6 +84,28 @@ window.addEventListener("unhandledrejection", (event) => {
}
return;
}
+ // An AbortError rejection is a cancellation we asked for, not a failure. Our own
+ // fetch chains handle it; the unhandled copies come from browser extensions that
+ // wrap window.fetch and derive a promise from each request without a rejection
+ // handler, so they reject with our abort reason whenever a thumbnail lease is
+ // released mid-fetch. Filtered before the cap so a scroll burst cannot exhaust
+ // ERROR_CAP and silence the session's real rejections. Sampled per distinct
+ // message, so an abort we have not seen before (e.g. our own "Aborted") is
+ // recorded once instead of drowning in the extension flood.
+ if (props.error_name === "AbortError") {
+ filteredAbortCount++;
+ const message = props.error_message.slice(0, 200);
+ const novel =
+ !seenAbortMessages.has(message) && seenAbortMessages.size < MAX_SEEN_ABORT_MESSAGES;
+ if (novel) seenAbortMessages.add(message);
+ if (novel || filteredAbortCount % 100 === 0) {
+ trackStudioEvent("abort_rejection_filtered", {
+ error_message: message,
+ total_filtered: filteredAbortCount,
+ });
+ }
+ return;
+ }
rejectionCount++;
if (rejectionCount > ERROR_CAP) {