From 5ba7a36aa652610965bf589d097285e24ab5490e Mon Sep 17 00:00:00 2001 From: Ray Tien Date: Thu, 29 Jan 2026 22:01:32 +0800 Subject: [PATCH] fix: prevent gateway crash on fetch failure with unknown cause (#3974). --- src/infra/unhandled-rejections.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/infra/unhandled-rejections.ts b/src/infra/unhandled-rejections.ts index d186c6a78..a4201c140 100644 --- a/src/infra/unhandled-rejections.ts +++ b/src/infra/unhandled-rejections.ts @@ -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; }