From c8c8b5dc06acc1b9874b85fbbcef8b2d1d6955c3 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 2 Oct 2024 07:14:24 +0200 Subject: [PATCH] fix(sync): handle 502 (Bad Gateway) gracefully This is the proxies response when the request to the server fails. It is often temporary - so it makes sense to keep trying. Signed-off-by: Max --- src/services/PollingBackend.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/services/PollingBackend.js b/src/services/PollingBackend.js index 3314f66e492..054bbcc865b 100644 --- a/src/services/PollingBackend.js +++ b/src/services/PollingBackend.js @@ -176,13 +176,10 @@ class PollingBackend { } else if (e.response.status === 412) { this.#syncService.emit('error', { type: ERROR_TYPE.LOAD_ERROR, data: e.response }) this.disconnect() - } else if (e.response.status === 403) { + } else if ([403, 404].includes(e.response.status)) { this.#syncService.emit('error', { type: ERROR_TYPE.SOURCE_NOT_FOUND, data: {} }) this.disconnect() - } else if (e.response.status === 404) { - this.#syncService.emit('error', { type: ERROR_TYPE.SOURCE_NOT_FOUND, data: {} }) - this.disconnect() - } else if (e.response.status === 503) { + } else if ([502, 503].includes(e.response.status)) { this.increaseRefetchTimer() this.#syncService.emit('error', { type: ERROR_TYPE.CONNECTION_FAILED, data: {} }) logger.error('Failed to fetch steps due to unavailable service', { error: e })