fix: prevent gateway crash on fetch failure with unknown cause (#3974).

This commit is contained in:
Ray Tien 2026-01-29 22:01:32 +08:00
parent 5f4715acfc
commit 5ba7a36aa6

View File

@ -84,7 +84,10 @@ export function isTransientNetworkError(err: unknown): boolean {
// "fetch failed" TypeError from undici (Node's native fetch)
if (err instanceof TypeError && err.message === "fetch failed") {
const cause = getErrorCause(err);
if (cause) return isTransientNetworkError(cause);
// Check cause for recognized network codes if available
if (cause && isTransientNetworkError(cause)) return true;
// Fallback: "fetch failed" is inherently a network error,
// even if cause lacks standard error codes (#3974)
return true;
}