fix: Reduce noise from XHR upload network errors (#12132)

Network-level upload failures (xhr.status === 0) now log as warnings
with extra context instead of unhelpful "Error: 0" reports in Sentry.
This commit is contained in:
Tom Moor
2026-04-21 19:34:39 -04:00
committed by GitHub
parent 1649b46778
commit d55c9ccc1f
+16 -1
View File
@@ -85,9 +85,24 @@ export const uploadFile = async (
}
});
xhr.addEventListener("error", () => {
const extra = {
status: xhr.status,
statusText: xhr.statusText,
contentType: file.type,
size: file.size,
};
// Status 0 means the request never reached the server (network drop,
// CORS, abort) — log as a warning rather than an unhelpful "Error: 0".
if (xhr.status === 0) {
Logger.warn("File upload failed before response", extra);
return;
}
Logger.error(
"File upload failed",
new Error(`${xhr.status} ${xhr.statusText}`)
new Error(`${xhr.status} ${xhr.statusText}`),
extra
);
});
xhr.addEventListener("loadend", () => {