From 0a17dd3cf0f7282eb3b4d0fd8846c063de419901 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sun, 22 Jan 2023 22:59:45 +0000 Subject: [PATCH] Fix handling timeouts as a temporary error --- src/util/errors.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/errors.ts b/src/util/errors.ts index 1037e17..f944abf 100644 --- a/src/util/errors.ts +++ b/src/util/errors.ts @@ -1,4 +1,5 @@ import createDebug from 'debug'; +import { AbortError } from 'node-fetch'; import Loop, { LoopResult } from './loop.js'; import { CoralErrorResponse } from '../api/coral-types.js'; import { ErrorResponse } from '../api/util.js'; @@ -32,6 +33,10 @@ export async function handleError( if (TemporaryErrorSymbol in err && err[TemporaryErrorSymbol]) { debug('Temporary error, waiting %ds before retrying', loop.update_interval, err); + return LoopResult.OK; + } else if (err instanceof AbortError) { + debug('Request aborted (timeout?), waiting %ds before retrying', loop.update_interval, err); + return LoopResult.OK; } else if ('code' in err && (err as any).type === 'system' && err.code && err.code in temporary_system_errors) { const desc = temporary_system_errors[err.code as keyof typeof temporary_system_errors];