mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 13:47:16 +00:00

Sometimes, the `parallel/test-tracing-no-crash` would not work as expected, at least on Windows, because there is a static destruction race between tearing down the `NodeTraceWriter` instance and the per-process options struct. If the per-process options were destroyed before the `NodeTraceWriter`, the reference to the tracing filename would be gone before opening the file was attempted. This can be solved by creating a copy of the string when creating the `NodeTraceWriter` instance rather than taking a reference. Fixes: https://github.com/nodejs/node/issues/22523 PR-URL: https://github.com/nodejs/node/pull/24123 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
23 lines
747 B
JavaScript
23 lines
747 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { spawn } = require('child_process');
|
|
|
|
function CheckNoSignalAndErrorCodeOne(code, signal) {
|
|
assert.strictEqual(signal, null);
|
|
assert.strictEqual(code, 1);
|
|
}
|
|
|
|
const child = spawn(process.execPath, [
|
|
'--trace-event-categories', 'madeup', '-e', 'throw new Error()'
|
|
], { stdio: [ 'inherit', 'inherit', 'pipe' ] });
|
|
child.on('exit', common.mustCall(CheckNoSignalAndErrorCodeOne));
|
|
|
|
let stderr;
|
|
child.stderr.setEncoding('utf8');
|
|
child.stderr.on('data', (chunk) => stderr += chunk);
|
|
child.stderr.on('end', common.mustCall(() => {
|
|
assert(stderr.includes('throw new Error()'), stderr);
|
|
assert(!stderr.includes('Could not open trace file'), stderr);
|
|
}));
|