Skip to content

Commit 3bfe0e2

Browse files
Trottgibfahn
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 52e573d commit 3bfe0e2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

test/common/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ exports.mustCallAtLeast = function(fn, minimum) {
506506
};
507507

508508
function _mustCallInner(fn, criteria = 1, field) {
509+
if (process._exiting)
510+
throw new Error('Cannot use common.mustCall*() in process exit handler');
509511
if (typeof fn === 'number') {
510512
criteria = fn;
511513
fn = noop;

0 commit comments

Comments
 (0)