Skip to content

Commit

Permalink
Merge pull request #3079 from OpenNeuroOrg/catch-connection-setup-issue
Browse files Browse the repository at this point in the history
fix(server): Gracefully handle getFile ECONNREFUSED when worker network is reconfiguring
  • Loading branch information
nellh authored Jun 15, 2024
2 parents 9eab62f + 72a8b7c commit f0facb3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/openneuro-server/src/handlers/datalad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0facb3

Please sign in to comment.