Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
e314681
src: use more stable cast where possible
gireeshpunathil Feb 12, 2019
143b844
meta: moving jasnell temporarily to TSC emeritus
jasnell Feb 14, 2019
1766b8c
trace_events: fix trace events JS API writing
kjin Dec 10, 2018
dd60cd6
test: add arg to narrow http benchmark test
refack Feb 14, 2019
2d0242a
test: increase coverage for assertion_error.js
Trott Feb 13, 2019
14cf22f
fs, src, lib: fix `blksize` & `blocks` on Windows
richardlau Feb 12, 2019
f408d78
build: fixed clang's warning when building openssl
thangktran Feb 6, 2019
77a944c
worker: use fake MessageEvent for port.onmessage
addaleax Feb 13, 2019
d1e3724
test,worker: add more tests for worker.ref()/.unref()
addaleax Feb 13, 2019
497d9d8
src: use same parameter name in node_report.cc
gengjiawen Feb 11, 2019
a920721
test: silence compiler warning in openssl-binding
danbev Feb 13, 2019
6929871
worker: switch to internal assert module
Trott Feb 14, 2019
8045e40
worker: remove duplicate call
gireeshpunathil Feb 14, 2019
2ff1644
doc: fix notable changes list format for 11.9.0 & 11.10.0
Schweinepriester Feb 15, 2019
0c4353a
inspector: make sure timer handles are cleaned up
addaleax Feb 14, 2019
b5fe27c
process: delay setup of global exception handlers
joyeecheung Feb 10, 2019
3971510
doc: fix changelog entry
cjihrig Feb 14, 2019
82bc68b
doc: fix notable changes in v11 changelog
targos Feb 15, 2019
a9c4437
doc: consolidate N-API material in Collaborator Guide
Trott Feb 14, 2019
0408966
src: remove unused macro in node_file.cc
gengjiawen Feb 13, 2019
24debc9
worker: do not add removed methods to MessagePort
addaleax Feb 14, 2019
7d66d47
vm: do not overwrite error when creating context
addaleax Feb 14, 2019
be671c3
inspector: forward errors from InspectorConsoleCall
addaleax Feb 14, 2019
cbd3cf0
src: add debug CHECKs against empty handles
addaleax Feb 15, 2019
1ce5e63
n-api: do not call into JS when that is not allowed
addaleax Feb 15, 2019
2335bcd
n-api: turn NAPI_CALL_INTO_MODULE into a function
addaleax Feb 15, 2019
f44f335
src: extract common sockaddr creation code
danbev Feb 13, 2019
d3525d7
test: add --test-root option to test.py
hashseed Feb 13, 2019
a18b847
doc: improve worker_threads documentation
addaleax Feb 14, 2019
db94ab7
test,worker: posting undefined/null message to message port
legendecas Feb 15, 2019
ee71952
src: check HasCaught() in JSStream calls
addaleax Feb 15, 2019
d550de4
src: remove inspector main_thread_request_ field
addaleax Feb 15, 2019
dab64bb
worker: spin uv_run twice before closing loop
addaleax Feb 15, 2019
441b545
test: fix flaky test-worker-ref-onexit
addaleax Feb 17, 2019
28d6074
tools: update ESLint to 5.14.0
cjihrig Feb 15, 2019
e6949b4
src: apply clang-tidy rule modernize-use-override
gengjiawen Feb 14, 2019
733beb7
lib: convert legacy process.binding to internalBinding
ZYSzys Feb 14, 2019
4ca0789
src: use PauseOnNextJavascriptStatement to implement --inspect-brk-node
joyeecheung Feb 10, 2019
778db67
src: remove invalid casts in options parser
addaleax Feb 15, 2019
dab3d71
worker: ignore --abort-on-uncaught-exception for terminate()
addaleax Feb 14, 2019
76c2f4f
test: simplify test-worker-syntax-error
Trott Feb 16, 2019
230e98b
process: start coverage collection before bootstrap
joyeecheung Feb 8, 2019
82df851
src: unify uptime base used across the code base
joyeecheung Feb 9, 2019
38a87d5
test: increase coverage of node_report_module.cc
richardlau Feb 14, 2019
f4955fd
benchmark,test: refactoring
refack Feb 15, 2019
c810ced
doc: wrap child_process.md at 80 characters
Trott Feb 15, 2019
4d1c87e
doc: remove all-caps shouting from child_process.md
Trott Feb 15, 2019
789b818
doc: remove unnecessary bold italics from child_process.md
Trott Feb 15, 2019
b48a04b
doc: remove unnecessary bold text from child_process.md
Trott Feb 15, 2019
e506f6a
doc: remove unnecessary italics from child_process.md
Trott Feb 15, 2019
e108c32
doc: eliminate use of "note that" from child_process.md
Trott Feb 15, 2019
59ca9e9
test: consolidate assertions in ipv6only test
Trott Feb 16, 2019
e5dae20
doc: remove deprecation definition in Collaborator Guide
Trott Feb 16, 2019
bf61050
lib: converted element to lowercase in tty.js
abshek Feb 14, 2019
8fac54a
doc: fix code lang in repl.md
gengjiawen Feb 13, 2019
25ddbc9
src: apply clang-tidy rule performance-unnecessary-value-param
gengjiawen Feb 11, 2019
b338edb
module: use compileFunction over Module.wrap
ryzokuken Jun 28, 2018
54896a6
module: revert module._compile to original state if module is patched
ryzokuken Nov 7, 2018
34c685b
tracing: use ‘real’ atomics
addaleax Feb 16, 2019
6b7d836
src: add missing includes for vtune build
Feb 15, 2019
fde4011
process: fix calculation in process.uptime()
joyeecheung Feb 19, 2019
cd10e25
process: move test-process-uptime to parallel
joyeecheung Feb 19, 2019
823f0ce
doc: revise Style Guide
Trott Feb 18, 2019
818b280
test: remove unnecessary default tmpdir value in test
Trott Feb 18, 2019
bd40a12
src: only call .ReThrow() if not terminating
addaleax Feb 15, 2019
a1fcde0
test: simplify test-api-getreport.js
cjihrig Feb 17, 2019
633c1ea
report: simplify TriggerNodeReport()
cjihrig Feb 17, 2019
a39cd45
src: remove `process.binding('config').fipsForced`
joyeecheung Feb 18, 2019
007b2fa
test: increase run time in test-worker-prof
addaleax Feb 17, 2019
c6d5af5
src: move req_wrap_queue to base class of ReqWrap
addaleax Feb 16, 2019
8881c0b
src: simplify InspectorConsoleCall
addaleax Feb 17, 2019
fbf6dd5
test,inspector: add heap allocation tracker test
addaleax Feb 14, 2019
dff0149
tools: update ESLint to 5.14.1
cjihrig Feb 18, 2019
0e89d7a
report: simplify OnFatalError() handling
cjihrig Feb 18, 2019
8a40468
report: remove verbose setting
cjihrig Feb 18, 2019
f0a8166
deps: backport ICU fix for ARM64 Windows
jkunkee Feb 14, 2019
5cc2574
src: move async hooks trace events setup to pre_execution.js
joyeecheung Feb 10, 2019
966546c
process: simplify the setup of async hooks trace events
joyeecheung Feb 10, 2019
dcbd907
test: add test for node.async_hooks tracing in workers
joyeecheung Feb 19, 2019
28758b8
test: add test for dynamically enabling node.async_hooks tracing
joyeecheung Feb 19, 2019
a3f7471
build,test: guard eslint with crypto check
danbev Feb 18, 2019
108c698
crypto: make ConvertKey clear openssl error stack
bnoordhuis Feb 16, 2019
5e44768
doc: revise deprecation level explanations in Collaborator Guide
Trott Feb 19, 2019
ddd71f4
src: move function from header to source file
bnoordhuis Feb 17, 2019
619b5e7
src: simplify loop arithmetic in `GetCPUInfo`
gireeshpunathil Feb 18, 2019
8a551b9
http2: shrink memory to match read data
addaleax Feb 19, 2019
831aa9a
src: make `node::SignalWrap::OnSignal` into lambda
gireeshpunathil Feb 18, 2019
206e4b0
deps: V8: backport 74571c8
BridgeAR Feb 4, 2019
4bf58ac
util: update set iterator entries inspection
BridgeAR Feb 5, 2019
7e26ca6
src: simplify AliasedBuffer lifetime management
addaleax Feb 18, 2019
ca18525
test: improve performance of test-crypto-timing-safe-equal-benchmarks
Trott Feb 21, 2019
3abdcfc
src: remove unimplemented method in class StreamPipe
gengjiawen Feb 19, 2019
dbbceda
build: tidy up comments in `create_expfile.sh`
richardlau Feb 20, 2019
bc11415
test: simplify test-api-nohooks.js
cjihrig Feb 20, 2019
6f9a764
test: remove node-report/test-api.js
cjihrig Feb 20, 2019
a9a2c58
worker: improve integration with native addons
addaleax Feb 17, 2019
70e463c
crypto: fix error condition in Verify::VerifyFinal
tniessen Feb 21, 2019
1333dcc
crypto: fix unencrypted DER PKCS8 parsing
tniessen Feb 21, 2019
57179a0
process: setup signal handler in prepareMainThreadExecution
joyeecheung Feb 10, 2019
b1e739d
process: move initialization of node-report into pre_execution.js
joyeecheung Feb 21, 2019
7e70233
worker: serialize errors if stack getter throws
Trott Feb 16, 2019
d915207
process: use common operations to define browser globals
joyeecheung Feb 21, 2019
68accb5
src: use smart pointer in UDPWrap::OnSend
danbev Feb 21, 2019
7f08e02
deps: V8: cherry-pick d3308d0
addaleax Feb 19, 2019
437bb25
src: make IsolateData store ArrayBufferAllocator
addaleax Feb 18, 2019
20dc172
worker: copy transferList ArrayBuffers on unknown allocator
addaleax Feb 19, 2019
238fa57
src: add debugging array allocator
addaleax Feb 18, 2019
2826076
src: add allocation utils to env
addaleax Feb 18, 2019
3c11b4e
src: allocate Buffer memory using ArrayBuffer allocator
addaleax Feb 18, 2019
ff57a1c
doc: clarify http.ClientRequest path description
JungMinu Feb 22, 2019
0080350
tools: update markdown linter
Trott Feb 23, 2019
0017855
url: handle quasi-WHATWG URLs in urlToOptions()
cjihrig Feb 21, 2019
0034820
errors: add ERR_INSPECTOR_COMMAND error
cjihrig Feb 21, 2019
b0c310d
inspector: return Error objects on error
cjihrig Feb 21, 2019
8e2cc5e
report: refactor triggerReport()
cjihrig Feb 22, 2019
a382b52
test: consolidate triggerReport() tests
cjihrig Feb 22, 2019
33fe892
test: increase triggerReport() coverage
cjihrig Feb 23, 2019
6d2a14d
report: refactor argument validation
cjihrig Feb 23, 2019
e8995d1
test: increase getReport() coverage
cjihrig Feb 23, 2019
88256d7
test: simplify node-report/test-exception.js
cjihrig Feb 23, 2019
d2d9453
report: simplify heap space iteration
cjihrig Feb 24, 2019
ba5f31a
report: use ru_stime for system CPU calculation
cjihrig Feb 24, 2019
8b515b2
src: apply clang-tidy rule modernize-deprecated-headers
gengjiawen Feb 17, 2019
4001b24
src: remove unimplemented method in class SSLWrap
gengjiawen Feb 19, 2019
c8d30a7
deps: update acorn to 6.1.0
gengjiawen Feb 14, 2019
3e0978d
src: clean unused macro in inspector_socket.cc
gengjiawen Feb 17, 2019
f636f15
repl: add more information
BridgeAR Feb 21, 2019
2fa8170
repl: add new line on ctrl+d
BridgeAR Feb 21, 2019
2a74a1e
repl: hide editor mode if not used in a terminal
BridgeAR Feb 21, 2019
1abe1d1
src: track memory retainer fields
gireeshpunathil Feb 18, 2019
d8f5f55
test: eliminate port collision
gireeshpunathil Feb 25, 2019
8584068
doc: revise deprecation semverness info in Collaborator Guide
Trott Feb 21, 2019
7612574
stream: make _read() be called indefinitely if the user wants so
mcollina Feb 15, 2019
2fe9886
report: fix build warning in node_report.cc
richardlau Feb 22, 2019
fa8110a
build: silence cpp lint by default
BridgeAR Feb 21, 2019
34905fc
util: mark iterator entries as such
BridgeAR Feb 20, 2019
40a5a93
doc: add example for setting Vary: Accept-Encoding header in zlib.md
mukulkhanna Feb 26, 2019
d6759db
src: remove cast for unsupported openssl
sam-github Feb 25, 2019
e72cb94
n-api: implement date object
jarrodconnolly Feb 4, 2019
7bf6309
doc: napi_get_value_bigint_words argument order
no2chem Feb 25, 2019
4500ed8
util: add compact depth mode
BridgeAR Feb 22, 2019
6828fbb
util: group array elements together
BridgeAR Feb 22, 2019
74d11e7
worker: refactor thread life cycle management
gireeshpunathil Feb 17, 2019
75ae77d
src: do not access Environment-owned handles after cleanup
addaleax Feb 21, 2019
33d6a3f
src: clean up `StreamPipe` in destructor
addaleax Feb 21, 2019
6d014a6
meta: remove the useless GitHub Account
Feb 16, 2019
6f9ab5e
src: remove redundant cast in method AfterStringPath
gengjiawen Feb 20, 2019
69154e4
test: refactor tick objects prune function
asattelmaier Feb 17, 2019
0c8e9ee
test: fix for activities in tick objects prune function
asattelmaier Feb 17, 2019
2a66cd3
module: simpler shebang function
BridgeAR Dec 31, 2018
d94f4c2
module: fix stat cache
BridgeAR Feb 22, 2019
b0cde2c
path: minor refactoring
BridgeAR Jan 27, 2019
6c44e68
path: more small refactorings
BridgeAR Jan 27, 2019
cccc44b
path: refactor more path code for simplicity
BridgeAR Jan 27, 2019
6c7cd9e
path: minor refactoring
BridgeAR Jan 27, 2019
55d6b49
path: refactor logic for to reduce code branches
BridgeAR Jan 27, 2019
e00c8cd
path: simplify code and remove obsolete checks
BridgeAR Jan 27, 2019
348f1fb
path: refactor for less indentation
BridgeAR Jan 27, 2019
5b8ac58
path: refactor code for clarity
BridgeAR Jan 27, 2019
0d660d9
readline: improve Unicode handling
Avi-D-coder Jan 26, 2019
c37b679
src: remove unused Converter object
addaleax Feb 21, 2019
51f01aa
worker: remove MessagePort::AddToIncomingQueue
addaleax Feb 23, 2019
6fdc502
worker: make MessagePort `uv_async_t` inline field
addaleax Feb 23, 2019
30f0a3b
src: remove dead inspector code
addaleax Feb 24, 2019
e2baa68
build: remove v8_typed_array_max_size_in_heap option
addaleax Feb 25, 2019
9b4eec0
src: allow not materializing ArrayBuffers from C++
addaleax Feb 25, 2019
5e4aa28
buffer: avoid materializing ArrayBuffer for creation
addaleax Feb 25, 2019
4561cf3
test: verify heap buffer allocations occur
addaleax Feb 25, 2019
ea26ac0
dns: refactor QueryWrap lifetime management
addaleax Feb 21, 2019
06d592c
src: simplify native immediate by using v8::Global
addaleax Feb 21, 2019
b62e228
report: add fallback for uv_getnameinfo() failures
richardlau Feb 15, 2019
af2a693
src: remove redundant cast in PipeWrap::Fchmod
gengjiawen Feb 21, 2019
4df82f0
src: remove unused macro in node_http2.h
gengjiawen Feb 19, 2019
8698255
doc: add documentation for the defaultPort option
lpinca Feb 16, 2019
3560c3a
doc: sort http.request() options alphabetically
lpinca Feb 16, 2019
adcbcf5
tools: use latest rather than next for markdown linting plugin
Trott Feb 28, 2019
347dd99
tools: update eslint-plugin-markdown to 1.0.0
Trott Feb 28, 2019
8cf4170
worker: provide process.execArgv
addaleax Feb 22, 2019
05e6ec0
build: make 'floating patch' message informational
bnoordhuis Feb 28, 2019
123fad6
tools: update babel-eslint to 10.0.1
Trott Feb 28, 2019
bc5771e
doc: correct typos in various docs
BeniCheni Feb 26, 2019
3f4b27d
doc: maxReservedRemoteStreams value constraints
sebdeckers Feb 26, 2019
d66cb4a
benchmark,doc,lib,test: capitalize comments
BridgeAR Jan 21, 2019
a70bafb
console: prevent constructing console methods
Hakerh400 Feb 10, 2019
7ccffcb
test: improve validation of report output
cjihrig Feb 24, 2019
11bd5e0
test: rename node-report suite to report
cjihrig Mar 1, 2019
8814d03
doc,lib,test: rename node-report to report
cjihrig Mar 1, 2019
6e9a7e1
tools: remove unneeded .gitignore entries
Trott Feb 28, 2019
96a5765
tools: update extend to 3.0.2
Trott Mar 2, 2019
2438a43
src: remove unused macro in env.cc
gengjiawen Feb 23, 2019
cb2cbf2
src: remove already elevated Isolate namespce
juanarbol Feb 24, 2019
030b744
esm: process proxy Symbol.toString fix
guybedford Feb 6, 2019
846cba0
doc: edit deprecation identifier info in Collaborator Guide
Trott Mar 1, 2019
91b6145
test: always activate colors if necessary
BridgeAR Feb 28, 2019
b6355ef
tty: improve color detection
BridgeAR Feb 22, 2019
93d7fa3
test: only inspect on failure
BridgeAR Jan 27, 2019
4c254d6
repl: use object writer for thrown errors
addaleax Feb 28, 2019
851a691
zlib: report premature ends earlier
addaleax Feb 28, 2019
b2c77ec
report: use triggerReport() to handle exceptions
cjihrig Mar 1, 2019
b216f44
src: remove unnecessary function declaration
cjihrig Mar 1, 2019
0579f42
report: use triggerReport() to handle signals
cjihrig Mar 1, 2019
3093617
src: remove unused variable
cjihrig Mar 1, 2019
2908e63
report: rename location to trigger
cjihrig Mar 2, 2019
b25694d
meta: update note about building on smartOS 16
refack Jan 24, 2019
3bc0123
inspector: print all listening addresses
bnoordhuis Feb 8, 2019
a41138b
test: remove duplicated buffer negative allocation test
ZYSzys Feb 17, 2019
50e42c9
test: improve test coverage in perf_hooks
juanarbol Feb 24, 2019
cb62c24
src: reduce to simple `const char*` in OptionsParser
ZYSzys Feb 25, 2019
63942de
src: extra-semi warning in node_platform.h
nornagon Feb 26, 2019
fc9ba36
src: fix typo in callback.cc
gengjiawen Feb 27, 2019
2595fbc
http2: improve compatibility with http/1
sagitsofan Oct 21, 2018
3c277d7
2019-03-06, Version 11.11.0 (Current)
BridgeAR Mar 4, 2019
6d774a7
Working on v11.11.1
BridgeAR Mar 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
trace_events: fix trace events JS API writing
The Trace Events JS API isn't functional if none of
--trace-events-enabled or --trace-event-categories is passed as a CLI
argument. This commit fixes that.

In addition, we currently don't test the trace_events JS API in the
casewhere no CLI args are provided. This commit adds that test.

Fixes #24944

PR-URL: #24945
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
  • Loading branch information
kjin authored and rvagg committed Feb 28, 2019
commit 1766b8c341a12d2224dd638c399b66b828bc1ca6
3 changes: 3 additions & 0 deletions src/node_trace_events.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ void NodeCategorySet::Enable(const FunctionCallbackInfo<Value>& args) {
CHECK_NOT_NULL(category_set);
const auto& categories = category_set->GetCategories();
if (!category_set->enabled_ && !categories.empty()) {
// Starts the Tracing Agent if it wasn't started already (e.g. through
// a command line flag.)
StartTracingAgent();
GetTracingAgentWriter()->Enable(categories);
category_set->enabled_ = true;
}
Expand Down
16 changes: 12 additions & 4 deletions src/node_v8_platform-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ struct V8Platform {
tracing_agent_->GetTracingController();
trace_state_observer_.reset(new NodeTraceStateObserver(controller));
controller->AddTraceStateObserver(trace_state_observer_.get());
StartTracingAgent();
tracing_file_writer_ = tracing_agent_->DefaultHandle();
// Only start the tracing agent if we enabled any tracing categories.
if (!per_process::cli_options->trace_event_categories.empty()) {
StartTracingAgent();
}
// Tracing must be initialized before platform threads are created.
platform_ = new NodePlatform(thread_pool_size, controller);
v8::V8::InitializePlatform(platform_);
Expand All @@ -111,9 +115,9 @@ struct V8Platform {
}

inline void StartTracingAgent() {
if (per_process::cli_options->trace_event_categories.empty()) {
tracing_file_writer_ = tracing_agent_->DefaultHandle();
} else {
// Attach a new NodeTraceWriter only if this function hasn't been called
// before.
if (tracing_file_writer_.IsDefaultHandle()) {
std::vector<std::string> categories =
SplitString(per_process::cli_options->trace_event_categories, ',');

Expand Down Expand Up @@ -163,6 +167,10 @@ namespace per_process {
extern struct V8Platform v8_platform;
}

inline void StartTracingAgent() {
return per_process::v8_platform.StartTracingAgent();
}

inline tracing::AgentWriterHandle* GetTracingAgentWriter() {
return per_process::v8_platform.GetTracingAgentWriter();
}
Expand Down
6 changes: 6 additions & 0 deletions src/tracing/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class AgentWriterHandle {
inline void Enable(const std::set<std::string>& categories);
inline void Disable(const std::set<std::string>& categories);

inline bool IsDefaultHandle();

inline Agent* agent() { return agent_; }

inline v8::TracingController* GetTracingController();
Expand Down Expand Up @@ -175,6 +177,10 @@ void AgentWriterHandle::Disable(const std::set<std::string>& categories) {
if (agent_ != nullptr) agent_->Disable(id_, categories);
}

bool AgentWriterHandle::IsDefaultHandle() {
return agent_ != nullptr && id_ == Agent::kDefaultHandleId;
}

inline v8::TracingController* AgentWriterHandle::GetTracingController() {
return agent_ != nullptr ? agent_->GetTracingController() : nullptr;
}
Expand Down
30 changes: 25 additions & 5 deletions test/parallel/test-trace-events-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ const {
getEnabledCategories
} = require('trace_events');

function getEnabledCategoriesFromCommandLine() {
const indexOfCatFlag = process.execArgv.indexOf('--trace-event-categories');
if (indexOfCatFlag === -1) {
return undefined;
} else {
return process.execArgv[indexOfCatFlag + 1];
}
}

const isChild = process.argv[2] === 'child';
const enabledCategories = isChild ? 'foo' : undefined;
const enabledCategories = getEnabledCategoriesFromCommandLine();

assert.strictEqual(getEnabledCategories(), enabledCategories);
[1, 'foo', true, false, null, undefined].forEach((i) => {
Expand Down Expand Up @@ -51,7 +60,9 @@ tracing.enable(); // purposefully enable twice to test calling twice
assert.strictEqual(tracing.enabled, true);

assert.strictEqual(getEnabledCategories(),
isChild ? 'foo,node.perf' : 'node.perf');
[
...[enabledCategories].filter((_) => !!_), 'node.perf'
].join(','));

tracing.disable();
assert.strictEqual(tracing.enabled, false);
Expand Down Expand Up @@ -106,7 +117,15 @@ if (isChild) {
}
}

testApiInChildProcess([], () => {
testApiInChildProcess(['--trace-event-categories', 'foo']);
});
}

function testApiInChildProcess(execArgs, cb) {
tmpdir.refresh();
// Save the current directory so we can chdir back to it later
const parentDir = process.cwd();
process.chdir(tmpdir.path);

const expectedMarks = ['A', 'B'];
Expand All @@ -121,15 +140,14 @@ if (isChild) {

const proc = cp.fork(__filename,
['child'],
{ execArgv: [ '--expose-gc',
'--trace-event-categories',
'foo' ] });
{ execArgv: [ '--expose-gc', ...execArgs ] });

proc.once('exit', common.mustCall(() => {
const file = path.join(tmpdir.path, 'node_trace.1.log');

assert(fs.existsSync(file));
fs.readFile(file, common.mustCall((err, data) => {
assert.ifError(err);
const traces = JSON.parse(data.toString()).traceEvents
.filter((trace) => trace.cat !== '__metadata');
assert.strictEqual(traces.length,
Expand Down Expand Up @@ -160,6 +178,8 @@ if (isChild) {
assert.fail('Unexpected trace event phase');
}
});
process.chdir(parentDir);
cb && process.nextTick(cb);
}));
}));
}