From 72a8b7ce4308918d332d15be0965a13fe1365909 Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Thu, 13 Jun 2024 14:18:05 -0700 Subject: [PATCH] fix(server): Gracefully handle ECONNREFUSED when worker network is reconfiguring --- packages/openneuro-server/src/handlers/datalad.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/openneuro-server/src/handlers/datalad.ts b/packages/openneuro-server/src/handlers/datalad.ts index 1b6066cba..96e333cb9 100644 --- a/packages/openneuro-server/src/handlers/datalad.ts +++ b/packages/openneuro-server/src/handlers/datalad.ts @@ -39,9 +39,11 @@ export const getFile = async (req, res) => { } } catch (err) { // ConnectTimeoutError is Node/Undici and TimeoutError is the standard DOMException name + // "fetch failed" can mean the connection failed at setup (network is unavailable) if ( err?.cause?.name === "ConnectTimeoutError" || - err?.name === "TimeoutError" + err?.name === "TimeoutError" || + err?.name === "TypeError" && err?.message.includes("fetch failed") ) { // Unreachable backend, forward this error // Usually this is the service restarting due to node migrations or upgrades