trace_events: stop tracing agent in process.exit()
PR-URL: https://github.com/nodejs/node/pull/18005 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
parent
acf56be536
commit
6aac05bf47
@ -2029,6 +2029,9 @@ static void WaitForInspectorDisconnect(Environment* env) {
|
|||||||
|
|
||||||
static void Exit(const FunctionCallbackInfo<Value>& args) {
|
static void Exit(const FunctionCallbackInfo<Value>& args) {
|
||||||
WaitForInspectorDisconnect(Environment::GetCurrent(args));
|
WaitForInspectorDisconnect(Environment::GetCurrent(args));
|
||||||
|
if (trace_enabled) {
|
||||||
|
v8_platform.StopTracingAgent();
|
||||||
|
}
|
||||||
exit(args[0]->Int32Value());
|
exit(args[0]->Int32Value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
test/parallel/test-trace-events-process-exit.js
Normal file
22
test/parallel/test-trace-events-process-exit.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const cp = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const FILE_NAME = 'node_trace.1.log';
|
||||||
|
|
||||||
|
common.refreshTmpDir();
|
||||||
|
process.chdir(common.tmpDir);
|
||||||
|
|
||||||
|
const proc = cp.spawn(process.execPath,
|
||||||
|
[ '--trace-events-enabled',
|
||||||
|
'-e', 'process.exit()' ]);
|
||||||
|
|
||||||
|
proc.once('exit', common.mustCall(() => {
|
||||||
|
assert(common.fileExists(FILE_NAME));
|
||||||
|
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
|
||||||
|
const traces = JSON.parse(data.toString()).traceEvents;
|
||||||
|
assert(traces.length > 0);
|
||||||
|
}));
|
||||||
|
}));
|
Loading…
x
Reference in New Issue
Block a user