mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(studio): stop composition fetch-404 flood and cap error telemetry
Two fixes for the 3M+ unhandled_promise_rejection events/day spike: 1. Filter: suppress "Error fetching ... 404" rejections from composition code — these are asset-not-found content errors, not Studio bugs. 2. Rate-limit: cap both error and rejection telemetry at 50 per session. After the cap, emit a single *_cap_reached event so we know capping occurred without generating unlimited events. 3. Root cause: webAudioTransport now checks response.ok before decode and caches failed URLs in _failedSrcs so repeat ticks don't re-fetch the same 404 on every playback frame. Also add playground/ to fallow ignorePatterns — local experiment directory was tripping the audit gate.
This commit is contained in:
@@ -22,6 +22,16 @@ function errorProps(value: unknown): {
|
||||
return { error_message: String(value), error_name: null, stack_trace: null };
|
||||
}
|
||||
|
||||
function isCompositionAssetError(msg: string): boolean {
|
||||
return msg.includes("Error fetching") && (msg.includes("404") || msg.includes("Not Found"));
|
||||
}
|
||||
|
||||
const ERROR_CAP = 50;
|
||||
let errorCount = 0;
|
||||
let rejectionCount = 0;
|
||||
let errorCapSent = false;
|
||||
let rejectionCapSent = false;
|
||||
|
||||
window.addEventListener("error", (event) => {
|
||||
if (event.message?.includes("ResizeObserver loop")) {
|
||||
event.stopImmediatePropagation();
|
||||
@@ -29,6 +39,15 @@ window.addEventListener("error", (event) => {
|
||||
return;
|
||||
}
|
||||
|
||||
errorCount++;
|
||||
if (errorCount > ERROR_CAP) {
|
||||
if (!errorCapSent) {
|
||||
errorCapSent = true;
|
||||
trackStudioEvent("error_cap_reached", { count: errorCount });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
trackStudioEvent("unhandled_error", {
|
||||
...errorProps(event.error),
|
||||
error_message: event.message,
|
||||
@@ -39,7 +58,19 @@ window.addEventListener("error", (event) => {
|
||||
});
|
||||
|
||||
window.addEventListener("unhandledrejection", (event) => {
|
||||
trackStudioEvent("unhandled_promise_rejection", errorProps(event.reason));
|
||||
const props = errorProps(event.reason);
|
||||
if (isCompositionAssetError(props.error_message)) return;
|
||||
|
||||
rejectionCount++;
|
||||
if (rejectionCount > ERROR_CAP) {
|
||||
if (!rejectionCapSent) {
|
||||
rejectionCapSent = true;
|
||||
trackStudioEvent("rejection_cap_reached", { count: rejectionCount });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
trackStudioEvent("unhandled_promise_rejection", props);
|
||||
});
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
|
||||
Reference in New Issue
Block a user