From b0e147c2c6b4eaf9ae5eef1c9a36fcb73a2cc0da Mon Sep 17 00:00:00 2001 From: sara castellano Date: Tue, 5 Mar 2024 14:57:14 +0100 Subject: [PATCH 1/3] move updateBackendStatus out of the condition Signed-off-by: sara castellano --- src/utils/work/waitForWorkRequest.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/utils/work/waitForWorkRequest.js b/src/utils/work/waitForWorkRequest.js index 956b03cf65..d5e14148cd 100644 --- a/src/utils/work/waitForWorkRequest.js +++ b/src/utils/work/waitForWorkRequest.js @@ -71,17 +71,22 @@ const waitForWorkRequest = async ( // the worker is alive and was working on another request of our experiment io.on(`Heartbeat-${experimentId}`, (message) => { const newTimeoutDate = getTimeoutDate(timeout); - if (newTimeoutDate < workerTimeoutDate) { - const status = { - worker: { - statusCode: message.status_code, - userMessage: message.user_message, - }, - }; - dispatch(updateBackendStatus(experimentId, status)); + // Log the newTimeoutDate and workerTimeoutDate + console.log('newTimeoutDate:', newTimeoutDate); + console.log('workerTimeoutDate:', workerTimeoutDate); + + if (newTimeoutDate < workerTimeoutDate) { setOrRefreshTimeout(request, timeout, reject, ETag); } + + const status = { + worker: { + statusCode: message.status_code, + userMessage: message.user_message, + }, + }; + dispatch(updateBackendStatus(experimentId, status)); }); }); From c4b4c30d46f641d70c7f0028ebbfd8e1bc6e5ca5 Mon Sep 17 00:00:00 2001 From: sara castellano Date: Tue, 5 Mar 2024 14:57:58 +0100 Subject: [PATCH 2/3] add console log to updateBackendStatus Signed-off-by: sara castellano --- src/redux/actions/backendStatus/updateBackendStatus.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/redux/actions/backendStatus/updateBackendStatus.js b/src/redux/actions/backendStatus/updateBackendStatus.js index ab0b445892..6f3f8c0d06 100644 --- a/src/redux/actions/backendStatus/updateBackendStatus.js +++ b/src/redux/actions/backendStatus/updateBackendStatus.js @@ -3,6 +3,9 @@ import { } from '../../actionTypes/backendStatus'; const updateBackendStatus = (experimentId, status) => async (dispatch) => { + // Log the payload before dispatching the action + console.log('Dispatching BACKEND_STATUS_UPDATED with payload:', { experimentId, status }); + dispatch({ type: BACKEND_STATUS_UPDATED, payload: { experimentId, status }, From e17362652f0c5d4b4ed937befaa3549b503834d9 Mon Sep 17 00:00:00 2001 From: sara castellano Date: Thu, 7 Mar 2024 10:23:55 +0100 Subject: [PATCH 3/3] remove console.logs Signed-off-by: sara castellano --- src/redux/actions/backendStatus/updateBackendStatus.js | 3 --- src/utils/work/waitForWorkRequest.js | 4 ---- 2 files changed, 7 deletions(-) diff --git a/src/redux/actions/backendStatus/updateBackendStatus.js b/src/redux/actions/backendStatus/updateBackendStatus.js index 6f3f8c0d06..ab0b445892 100644 --- a/src/redux/actions/backendStatus/updateBackendStatus.js +++ b/src/redux/actions/backendStatus/updateBackendStatus.js @@ -3,9 +3,6 @@ import { } from '../../actionTypes/backendStatus'; const updateBackendStatus = (experimentId, status) => async (dispatch) => { - // Log the payload before dispatching the action - console.log('Dispatching BACKEND_STATUS_UPDATED with payload:', { experimentId, status }); - dispatch({ type: BACKEND_STATUS_UPDATED, payload: { experimentId, status }, diff --git a/src/utils/work/waitForWorkRequest.js b/src/utils/work/waitForWorkRequest.js index d5e14148cd..17ee8ce41f 100644 --- a/src/utils/work/waitForWorkRequest.js +++ b/src/utils/work/waitForWorkRequest.js @@ -72,10 +72,6 @@ const waitForWorkRequest = async ( io.on(`Heartbeat-${experimentId}`, (message) => { const newTimeoutDate = getTimeoutDate(timeout); - // Log the newTimeoutDate and workerTimeoutDate - console.log('newTimeoutDate:', newTimeoutDate); - console.log('workerTimeoutDate:', workerTimeoutDate); - if (newTimeoutDate < workerTimeoutDate) { setOrRefreshTimeout(request, timeout, reject, ETag); }