Skip to content

Commit 7bf6be0

Browse files
AndreasMadsenMylesBorins
authored andcommitted
trace_events: stop tracing agent in process.exit()
PR-URL: #18005 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent b593d94 commit 7bf6be0

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/node.cc

+3
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,9 @@ static void WaitForInspectorDisconnect(Environment* env) {
23582358

23592359
static void Exit(const FunctionCallbackInfo<Value>& args) {
23602360
WaitForInspectorDisconnect(Environment::GetCurrent(args));
2361+
if (trace_enabled) {
2362+
v8_platform.StopTracingAgent();
2363+
}
23612364
exit(args[0]->Int32Value());
23622365
}
23632366

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const cp = require('child_process');
5+
const fs = require('fs');
6+
7+
const FILE_NAME = 'node_trace.1.log';
8+
9+
common.refreshTmpDir();
10+
process.chdir(common.tmpDir);
11+
12+
const proc = cp.spawn(process.execPath,
13+
[ '--trace-events-enabled',
14+
'-e', 'process.exit()' ]);
15+
16+
proc.once('exit', common.mustCall(() => {
17+
assert(common.fileExists(FILE_NAME));
18+
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
19+
const traces = JSON.parse(data.toString()).traceEvents;
20+
assert(traces.length > 0);
21+
}));
22+
}));

0 commit comments

Comments
 (0)