Skip to content

Commit a68fc9e

Browse files
authored
fix: --cpu-prof not working in child_process (#238)
1 parent 86a405a commit a68fc9e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/core/src/runtime/worker/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
TestFileResult,
66
WorkerState,
77
} from '../../types';
8+
import './setup';
89
import { globalApis } from '../../utils/constants';
910
import { undoSerializableConfig } from '../../utils/helper';
1011
import { formatTestError } from '../util';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const gracefulExit: boolean = process.execArgv.some(
2+
(execArg) =>
3+
execArg.startsWith('--prof') ||
4+
execArg.startsWith('--cpu-prof') ||
5+
execArg.startsWith('--heap-prof') ||
6+
execArg.startsWith('--diagnostic-dir'),
7+
);
8+
9+
if (gracefulExit) {
10+
// gracefully handle SIGTERM to generate CPU profile
11+
// https://github.com/nodejs/node/issues/55094
12+
process.on('SIGTERM', () => {
13+
process.exit();
14+
});
15+
}

0 commit comments

Comments
 (0)