From 3b06d7931bedb0306ebd948888092db0ff65877a Mon Sep 17 00:00:00 2001 From: Roman Letsuk Date: Wed, 15 Nov 2023 14:44:51 +0200 Subject: [PATCH] handle 504 response from service worker in offline mode for file request --- src/providers/storage/xhr.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/providers/storage/xhr.js b/src/providers/storage/xhr.js index 51f9c8f24c..cb15e70299 100644 --- a/src/providers/storage/xhr.js +++ b/src/providers/storage/xhr.js @@ -49,6 +49,12 @@ const XHR = { throw err; } if (!response.ok) { + if (response.status === 504) { + const error = new Error('Network request failed'); + error.networkError = true; + throw error; + } + const message = await response.text(); throw new Error(message || 'Unable to sign file.'); } @@ -95,6 +101,11 @@ const XHR = { if (xhr.status >= 200 && xhr.status < 300) { resolve(serverResponse); } + else if (xhr.status === 504) { + const error = new Error('Network request failed'); + error.networkError = true; + reject(error); + } else { reject(xhr.response || 'Unable to upload file'); }