Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ddf0297

Browse filesBrowse files
brindashar4danielleadams
authored andcommitted
test: use async/await in test-debugger-heap-profiler
PR-URL: #44693 Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent e0fbba0 commit ddf0297
Copy full SHA for ddf0297

File tree

Expand file treeCollapse file tree

1 file changed

+14
-13
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-13
lines changed
Open diff view settings
Collapse file

‎test/sequential/test-debugger-heap-profiler.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-debugger-heap-profiler.js
+14-13Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@ const filename = path.join(tmpdir.path, 'node.heapsnapshot');
1919
const opts = { cwd: tmpdir.path };
2020
const cli = startCLI([fixtures.path('debugger/empty.js')], [], opts);
2121

22-
function onFatal(error) {
23-
cli.quit();
24-
throw error;
22+
async function waitInitialBreak() {
23+
try {
24+
await cli.waitForInitialBreak();
25+
await cli.waitForPrompt();
26+
await cli.command('takeHeapSnapshot()');
27+
JSON.parse(readFileSync(filename, 'utf8'));
28+
// Check that two simultaneous snapshots don't step all over each other.
29+
// Refs: https://github.com/nodejs/node/issues/39555
30+
await cli.command('takeHeapSnapshot(); takeHeapSnapshot()');
31+
JSON.parse(readFileSync(filename, 'utf8'));
32+
} finally {
33+
await cli.quit();
34+
}
2535
}
2636

2737
// Check that the snapshot is valid JSON.
28-
return cli.waitForInitialBreak()
29-
.then(() => cli.waitForPrompt())
30-
.then(() => cli.command('takeHeapSnapshot()'))
31-
.then(() => JSON.parse(readFileSync(filename, 'utf8')))
32-
// Check that two simultaneous snapshots don't step all over each other.
33-
// Refs: https://github.com/nodejs/node/issues/39555
34-
.then(() => cli.command('takeHeapSnapshot(); takeHeapSnapshot()'))
35-
.then(() => JSON.parse(readFileSync(filename, 'utf8')))
36-
.then(() => cli.quit())
37-
.then(null, onFatal);
38+
waitInitialBreak().then(common.mustCall());
3839
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.