0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

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:
Rich Trott 2017-12-04 05:46:40 -08:00
parent 3549d9c2bc
commit 591a24b819

View File

@ -493,6 +493,8 @@ exports.mustCallAtLeast = function(fn, minimum) {
};
function _mustCallInner(fn, criteria = 1, field) {
if (process._exiting)
throw new Error('Cannot use common.mustCall*() in process exit handler');
if (typeof fn === 'number') {
criteria = fn;
fn = noop;