Skip to content

Commit e6a127b

Browse files
authored
Merge pull request #521 from HarperFast/fix/process-on-close-inspector
Close the inspector when the process receives an exit signal
2 parents e92cbb2 + f993791 commit e6a127b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

server/threads/threadServer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ if (!isBun) {
3131
let port;
3232
if (isMainThread) {
3333
port = env.get(terms.CONFIG_PARAMS.THREADS_DEBUG_PORT) ?? 9229;
34-
process.on(['SIGINT', 'SIGTERM', 'SIGQUIT', 'exit'], () => {
34+
const closeInspector = () => {
3535
try {
3636
require('inspector').close();
3737
} catch (error) {
3838
harperLogger.info('Could not close debugger', error);
3939
}
40-
});
40+
};
41+
for (const signal of ['SIGINT', 'SIGTERM', 'SIGQUIT', 'exit']) {
42+
process.on(signal, closeInspector);
43+
}
4144
} else {
4245
const startingPort = env.get(terms.CONFIG_PARAMS.THREADS_DEBUG_STARTINGPORT);
4346
if (startingPort && getWorkerIndex() >= 0) {

0 commit comments

Comments
 (0)