Skip to content

Commit

Permalink
trace_events: stop tracing agent in process.exit()
Browse files Browse the repository at this point in the history
PR-URL: #18005
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
  • Loading branch information
AndreasMadsen committed Jan 8, 2018
1 parent acf56be commit 6aac05b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,9 @@ static void WaitForInspectorDisconnect(Environment* env) {

static void Exit(const FunctionCallbackInfo<Value>& args) {
WaitForInspectorDisconnect(Environment::GetCurrent(args));
if (trace_enabled) {
v8_platform.StopTracingAgent();
}
exit(args[0]->Int32Value());
}

Expand Down
22 changes: 22 additions & 0 deletions test/parallel/test-trace-events-process-exit.js
Original file line number Diff line number Diff line change
@@ -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);
}));
}));

0 comments on commit 6aac05b

Please sign in to comment.