nx 21.5.2 → 21.6.0-canary.20250912-cfc03a2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/src/core/graph/main.js +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/tasks-runner/fork.js +31 -5
Binary file
|
package/src/tasks-runner/fork.js
CHANGED
@@ -20,26 +20,52 @@ const childProcess = (0, child_process_1.fork)(script, {
|
|
20
20
|
const pseudoIPC = new pseudo_ipc_1.PseudoIPCClient(pseudoIPCPath);
|
21
21
|
pseudoIPC.onMessageFromParent(forkId, (message) => {
|
22
22
|
childProcess.send(message);
|
23
|
+
}, () => {
|
24
|
+
// IPC connection closed
|
25
|
+
cleanup();
|
26
|
+
process.exit(0);
|
27
|
+
}, () => {
|
28
|
+
// IPC connection error
|
29
|
+
cleanup();
|
30
|
+
process.exit(0);
|
23
31
|
});
|
24
32
|
pseudoIPC.notifyChildIsReady(forkId);
|
25
33
|
process.on('message', (message) => {
|
26
34
|
pseudoIPC.sendMessageToParent(message);
|
27
35
|
});
|
28
36
|
childProcess.on('exit', (code) => {
|
29
|
-
|
37
|
+
cleanup();
|
30
38
|
process.exit(code);
|
31
39
|
});
|
40
|
+
let isCleaningUp = false;
|
41
|
+
function cleanup() {
|
42
|
+
if (isCleaningUp) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
isCleaningUp = true;
|
46
|
+
// Kill child process if still running
|
47
|
+
if (childProcess && !childProcess.killed) {
|
48
|
+
childProcess.kill('SIGTERM');
|
49
|
+
}
|
50
|
+
// Close IPC connection
|
51
|
+
try {
|
52
|
+
pseudoIPC.close();
|
53
|
+
}
|
54
|
+
catch {
|
55
|
+
// Ignore errors when closing, connection might already be broken
|
56
|
+
}
|
57
|
+
}
|
32
58
|
// Terminate the child process when exiting
|
33
59
|
process.on('exit', () => {
|
34
|
-
|
60
|
+
cleanup();
|
35
61
|
});
|
36
62
|
process.on('SIGINT', () => {
|
37
|
-
|
63
|
+
cleanup();
|
38
64
|
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
39
65
|
});
|
40
66
|
process.on('SIGTERM', () => {
|
41
|
-
|
67
|
+
cleanup();
|
42
68
|
});
|
43
69
|
process.on('SIGHUP', () => {
|
44
|
-
|
70
|
+
cleanup();
|
45
71
|
});
|