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: https://github.com/nodejs/node/pull/17453 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
3549d9c2bc
commit
591a24b819
@ -493,6 +493,8 @@ exports.mustCallAtLeast = function(fn, minimum) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function _mustCallInner(fn, criteria = 1, field) {
|
function _mustCallInner(fn, criteria = 1, field) {
|
||||||
|
if (process._exiting)
|
||||||
|
throw new Error('Cannot use common.mustCall*() in process exit handler');
|
||||||
if (typeof fn === 'number') {
|
if (typeof fn === 'number') {
|
||||||
criteria = fn;
|
criteria = fn;
|
||||||
fn = noop;
|
fn = noop;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user