From 192495d44a634b4c5d36c337dce9793e50fdb1bb Mon Sep 17 00:00:00 2001 From: 00Fjongl <65314359+00Fjongl@users.noreply.github.com> Date: Wed, 7 Aug 2024 16:37:29 -0500 Subject: [PATCH] Resolve run-command.mjs waiting periods --- run-command.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run-command.mjs b/run-command.mjs index fb300e24..cf5c8601 100644 --- a/run-command.mjs +++ b/run-command.mjs @@ -54,14 +54,16 @@ for(let i = 2; i < process.argv.length; i++) case "stop": await writeFile(shutdown, ""); try { + let timeoutId = undefined; const response = await Promise.race([ fetch(new URL("/test-shutdown", serverUrl)), new Promise(resolve => { - setTimeout(() => { + timeoutId = setTimeout(() => { resolve("Error"); }, 5000); }) ]); + clearTimeout(timeoutId); if(response === "Error") throw new Error("Server is unresponsive."); } catch (e) {await unlink(shutdown)} if (config.production)