Skip to content

Commit

Permalink
Resolve run-command.mjs waiting periods
Browse files Browse the repository at this point in the history
  • Loading branch information
00Fjongl committed Aug 7, 2024
1 parent 6412190 commit 192495d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion run-command.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 192495d

Please sign in to comment.