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)