From 4fc131de66288696a9fd84b16d470cf942d99034 Mon Sep 17 00:00:00 2001 From: Beverly Nguyen Date: Wed, 17 Sep 2025 10:00:29 -0700 Subject: [PATCH] update error handling --- app/assets/javascripts/socketio.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/socketio.js b/app/assets/javascripts/socketio.js index 41910bc3c..b7492b277 100644 --- a/app/assets/javascripts/socketio.js +++ b/app/assets/javascripts/socketio.js @@ -28,7 +28,9 @@ document.addEventListener('DOMContentLoaded', function () { } async function updateAllJobSections() { - if (document.hidden || isPolling) return; + if (isPolling || document.hidden) { + return; + } isPolling = true; const startTime = Date.now(); @@ -43,6 +45,9 @@ document.addEventListener('DOMContentLoaded', function () { try { const response = await fetch(url); + if (!response.ok) { + throw new Error(`HTTP ${response.status}: ${response.statusText}`); + } const data = await response.json(); const sections = { @@ -69,7 +74,12 @@ document.addEventListener('DOMContentLoaded', function () { } } catch (error) { - console.error('Error fetching job updates:', error); + console.error('Error fetching job updates:', { + error: error.message, + url: url, + jobId: jobId, + timestamp: new Date().toISOString() + }); currentInterval = Math.min(currentInterval * 2, MAX_INTERVAL_MS); } finally { isPolling = false;