Skip to content

Commit

Permalink
Merge pull request #5405 from formio/fix/file-request-in-offline-mode-5x
Browse files Browse the repository at this point in the history
FIO-7481: handle 504 response from service worker in offline mode for file request
  • Loading branch information
brendanbond authored Nov 21, 2023
2 parents f674280 + 3b06d79 commit b564156
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/providers/storage/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit b564156

Please sign in to comment.