From 5e3ef2078586aff1a5115c747a85c34c48007b9a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 17 May 2021 15:48:27 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20race=20condition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nest_frontend/utils/goToOnSuccess.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nest_frontend/utils/goToOnSuccess.js b/nest_frontend/utils/goToOnSuccess.js index 23388c0..2095a28 100644 --- a/nest_frontend/utils/goToOnSuccess.js +++ b/nest_frontend/utils/goToOnSuccess.js @@ -7,16 +7,17 @@ * @returns {(function(): void)|*} */ export default function goToOnSuccess(func, history, destination) { - return (...args) => { + return async (...args) => { let result try { - console.debug("Provando ad eseguire: ", func) - result = func(...args) + console.debug("Executing: ", func) + result = await func(...args) + console.debug("Executed successfully: ", func, " moving to a different page.") history.push(destination) return result } catch(e) { - console.debug("Esecuzione fallita: ", func, ", non ha fatto nulla.") + console.debug("Execution failed: ", func, ", not doing anything.") throw e } }