Skip to content

Commit 26a5d9a

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 fddba18 commit 26a5d9a

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+
thrownewError('Cannot use common.mustCall*() in process exit handler');
509511
if(typeoffn==='number'){
510512
criteria=fn;
511513
fn=noop;

0 commit comments

Comments
(0)