1
- const { dirname, extname } = require ( 'path' ) ;
2
- const childProcess = require ( 'child_process' ) ;
1
+ const childProcess = require ( 'node:child_process' ) ;
2
+ const { dirname, extname } = require ( 'node:path' ) ;
3
+ const { isMainThread } = require ( 'node:worker_threads' ) ;
3
4
const { sync : resolve } = require ( 'resolve' ) ;
4
- const { isMainThread } = require ( 'worker_threads' ) ;
5
5
6
6
const { getConfig } = require ( './cfg' ) ;
7
7
const hook = require ( './hook' ) ;
8
8
const { relay, send } = require ( './ipc' ) ;
9
+ const { registerLoader } = require ( './register-loader' ) ;
9
10
const resolveMain = require ( './resolve-main' ) ;
10
11
const suppressExperimentalWarnings = require ( './suppress-experimental-warnings' ) ;
11
12
@@ -25,8 +26,14 @@ if (process.env.NODE_DEV_PRELOAD) {
25
26
require ( process . env . NODE_DEV_PRELOAD ) ;
26
27
}
27
28
28
- // We want to exit on SIGTERM, but defer to existing SIGTERM handlers.
29
- process . once ( 'SIGTERM' , ( ) => process . listenerCount ( 'SIGTERM' ) || process . exit ( 0 ) ) ;
29
+ const port = registerLoader ( ) ;
30
+
31
+ process . once ( 'SIGTERM' , ( ) => {
32
+ port ?. close ( ) ;
33
+ // We want to exit on SIGTERM, but defer to existing SIGTERM handlers.
34
+ if ( process . listenerCount ( 'SIGTERM' ) ) return ;
35
+ process . exit ( 0 ) ;
36
+ } ) ;
30
37
31
38
if ( fork ) {
32
39
// Overwrite child_process.fork() so that we can hook into forked processes
0 commit comments