Skip to content

Commit 97b96b4

Browse files
committed
test: add known issues test for debugger heap snapshot race
Refs: #39555
1 parent 72ccf9f commit 97b96b4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
// Refs: https://github.com/nodejs/node/issues/39555
5+
6+
// After this issue is fixed, this can perhaps be integrated into
7+
// test/sequential/test-debugger-heap-profiler.js as it shares almost all
8+
// the same code.
9+
10+
common.skipIfInspectorDisabled();
11+
12+
if (!common.isMainThread) {
13+
common.skip('process.chdir() is not available in workers');
14+
}
15+
16+
const fixtures = require('../common/fixtures');
17+
const startCLI = require('../common/debugger');
18+
const tmpdir = require('../common/tmpdir');
19+
20+
tmpdir.refresh();
21+
process.chdir(tmpdir.path);
22+
23+
const { readFileSync } = require('fs');
24+
25+
const filename = 'node.heapsnapshot';
26+
27+
// Check that two simultaneous snapshots don't step all over each other.
28+
{
29+
const cli = startCLI([fixtures.path('debugger/empty.js')]);
30+
31+
function onFatal(error) {
32+
cli.quit();
33+
throw error;
34+
}
35+
36+
return cli.waitForInitialBreak()
37+
.then(() => cli.waitForPrompt())
38+
.then(() => cli.command('takeHeapSnapshot(); takeHeapSnapshot()'))
39+
.then(() => cli.command())
40+
.then(() => JSON.parse(readFileSync(filename, 'utf8')))
41+
.then(() => cli.quit())
42+
.then(null, onFatal);
43+
}

0 commit comments

Comments
 (0)