Skip to content
Closed
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion test/addons/callback-scope/test-resolve-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const common = require('../../common');
const assert = require('assert');
const { testResolveAsync } = require(`./build/${common.buildType}/binding`);

// Checks that resolving promises from C++ works.

let called = false;
testResolveAsync().then(() => { called = true; });

setTimeout(() => { assert(called); }, common.platformTimeout(50));
process.on('beforeExit', () => { assert(called); });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use common.mustCall? It uses essentially the same mechanism

node/test/common/index.js

Lines 428 to 429 in b85baf7

// add the exit listener only once to avoid listener leak warnings
if (mustCallChecks.length === 0) process.on('exit', runCallChecks);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to have no MakeCallback() calls coming from Node.js before the check is run, since those would also run the microtask queue. process.on('exit') would be too late for that, process.on('beforeExit') should be okay.