From 7380d27d78d7462331eef18a99815d789c684806 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 31 Aug 2021 14:54:02 -0500 Subject: [PATCH] js: fix null xhr in autosave error handling Sentry reports many cases of the xhr object being missing in the error handler. Ensure the error handling code doesn't crash because of the missing xhr. --- app/javascript/new_design/dossiers/auto-save.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/new_design/dossiers/auto-save.js b/app/javascript/new_design/dossiers/auto-save.js index d51bd1dda..1db6f8a25 100644 --- a/app/javascript/new_design/dossiers/auto-save.js +++ b/app/javascript/new_design/dossiers/auto-save.js @@ -64,7 +64,7 @@ addEventListener('autosave:end', () => { addEventListener('autosave:error', (event) => { let error = event.detail; - if (error.xhr.status == 401) { + if (error.xhr && error.xhr.status == 401) { // If we are unauthenticated, reload the page using a GET request. // This will allow Devise to properly redirect us to sign-in, and then back to this page. document.location.reload();