Skip to content

Commit 3c514df

Browse files
authored
fix systeminformation thread not ending (#4155)
This was introduced when running systeminformation in an own thread. If the main thread ends before (e.g. when config has errors) the systeminformation thread never ends. As this can have side effects under pm2 or docker (because the app never exits) this PR restores the old behavior.
1 parent d4a5ebe commit 3c514df

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

js/app.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,20 @@ function App () {
328328
await this.stop();
329329
process.exit(0);
330330
});
331+
332+
/**
333+
*
334+
* @param {number} ms milliseconds to wait
335+
*/
336+
function blockingSleep (ms) {
337+
const int32 = new Int32Array(new SharedArrayBuffer(4));
338+
Atomics.wait(int32, 0, 0, ms);
339+
}
340+
341+
process.on("exit", () => {
342+
// wait before exiting so that child processes (e.g. systeminformation) have some additional time
343+
blockingSleep(1000);
344+
});
331345
}
332346

333347
module.exports = new App();

0 commit comments

Comments
 (0)