fix: handle Discord gateway metadata fetch failures (#44397)

Merged via squash.

Prepared head SHA: edd17c0eff
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
Josh Lehman
2026-03-12 21:52:17 -07:00
committed by GitHub
parent 8023f4c701
commit 6d0939d84e
5 changed files with 257 additions and 35 deletions

View File

@@ -130,6 +130,13 @@ describe("isTransientNetworkError", () => {
expect(isTransientNetworkError(error)).toBe(true);
});
it("returns true for wrapped Discord upstream-connect parse failures", () => {
const error = new Error(
`Failed to get gateway information from Discord: Unexpected token 'u', "upstream connect error or disconnect/reset before headers. reset reason: overflow" is not valid JSON`,
);
expect(isTransientNetworkError(error)).toBe(true);
});
it("returns false for non-network fetch-failed wrappers from tools", () => {
const error = new Error("Web fetch failed (404): Not Found");
expect(isTransientNetworkError(error)).toBe(false);

View File

@@ -61,6 +61,8 @@ const TRANSIENT_NETWORK_MESSAGE_SNIPPETS = [
"network error",
"network is unreachable",
"temporary failure in name resolution",
"upstream connect error",
"disconnect/reset before headers",
"tlsv1 alert",
"ssl routines",
"packet length too long",