Skip to content

Commit 0ade488

Browse files
TrottMylesBorins
authored andcommitted
test: forbid common.mustCall*() in process exit handlers
`common.mustCall()` and `common.mustCallAtLeast()` need to be called before process exit handlers to work because checks are done inside a process exit handler. Detect if being used inside a process exit handler and throw. PR-URL: #17453 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 85e6271 commit 0ade488

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

test/common/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ exports.mustCallAtLeast = function(fn, minimum) {
493493
};
494494

495495
function _mustCallInner(fn, criteria = 1, field) {
496+
if (process._exiting)
497+
throw new Error('Cannot use common.mustCall*() in process exit handler');
496498
if (typeof fn === 'number') {
497499
criteria = fn;
498500
fn = noop;

0 commit comments

Comments
 (0)