Skip to content

Commit cff2aea

Browse files
Trottdanielleadams
authored andcommitted
test: add known issues test for debugger heap snapshot race
Refs: #39555 PR-URL: #39557 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 7514405 commit cff2aea

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
// These skips should be uncommented once the issue is fixed.
11+
// common.skipIfInspectorDisabled();
12+
13+
// if (!common.isMainThread) {
14+
// common.skip('process.chdir() is not available in workers');
15+
// }
16+
17+
// This assert.fail() can be removed once the issue is fixed.
18+
if (!common.hasCrypto || !process.features.inspector) {
19+
require('assert').fail('crypto is not available');
20+
}
21+
22+
const fixtures = require('../common/fixtures');
23+
const startCLI = require('../common/debugger');
24+
const tmpdir = require('../common/tmpdir');
25+
26+
tmpdir.refresh();
27+
process.chdir(tmpdir.path);
28+
29+
const { readFileSync } = require('fs');
30+
31+
const filename = 'node.heapsnapshot';
32+
33+
// Check that two simultaneous snapshots don't step all over each other.
34+
{
35+
const cli = startCLI([fixtures.path('debugger/empty.js')]);
36+
37+
function onFatal(error) {
38+
cli.quit();
39+
throw error;
40+
}
41+
42+
return cli.waitForInitialBreak()
43+
.then(() => cli.waitForPrompt())
44+
.then(() => cli.command('takeHeapSnapshot(); takeHeapSnapshot()'))
45+
.then(() => JSON.parse(readFileSync(filename, 'utf8')))
46+
.then(() => cli.quit())
47+
.then(null, onFatal);
48+
}

0 commit comments

Comments
 (0)