From 99fa6b4b1284920f8565e8fc84e0948a9d263298 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 17 Feb 2021 17:45:43 +0100 Subject: [PATCH] Set blocking on logging before process.exit On windows the terminal output is asynchronous by default which leads to log lines being lost if text is written to stdout before calling process.exit. Fix by using setBlocking before doing the log call. --- packages/master/master.js | 2 ++ packages/slave/slave.js | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/master/master.js b/packages/master/master.js index 55f0da3a..0ff2f37a 100755 --- a/packages/master/master.js +++ b/packages/master/master.js @@ -1957,6 +1957,7 @@ async function startServer(args) { let secondSigint = false; process.on("SIGINT", () => { if (secondSigint) { + setBlocking(true); logger.fatal("Caught second interrupt, terminating immediately"); // eslint-disable-next-line no-process-exit process.exit(1); @@ -1969,6 +1970,7 @@ async function startServer(args) { let secondSigterm = false; process.on("SIGTERM", () => { if (secondSigterm) { + setBlocking(true); logger.fatal("Caught second termination, terminating immediately"); // eslint-disable-next-line no-process-exit process.exit(1); diff --git a/packages/slave/slave.js b/packages/slave/slave.js index 120df4de..5998c29f 100755 --- a/packages/slave/slave.js +++ b/packages/slave/slave.js @@ -1404,6 +1404,7 @@ class Slave extends libLink.Link { // Clear silly interval in pidfile library. pidusage.clear(); } catch (err) { + setBlocking(true); logger.error(` +--------------------------------------------------------------------+ | Unexpected error occured while shutting down slave, please report |