Skip to content

Commit 6168067

Browse files
soulee-devaduh95
authored andcommitted
async_hooks: use validateBoolean for trackPromises
The `trackPromises` check duplicated `validateBoolean()` exactly: same error code, same expected type string, same argument order. Replace it with the validator, matching how this file already validates `type` and `fn` via `validateString()`/`validateFunction()`. `ERR_INVALID_ARG_TYPE` had no other use in this file, so drop the import. Since `validateBoolean` is wrapped in `hideStackFrames()`, the thrown error is unchanged from a caller's perspective. Signed-off-by: Soul Lee <alus20x@gmail.com> PR-URL: #64731 Refs: #61415 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent b95e5f9 commit 6168067

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/async_hooks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ const {
1818
ERR_ASYNC_CALLBACK,
1919
ERR_ASYNC_TYPE,
2020
ERR_INVALID_ASYNC_ID,
21-
ERR_INVALID_ARG_TYPE,
2221
ERR_INVALID_ARG_VALUE,
2322
} = require('internal/errors').codes;
2423
const {
2524
kEmptyObject,
2625
} = require('internal/util');
2726
const {
27+
validateBoolean,
2828
validateFunction,
2929
validateString,
3030
} = require('internal/validators');
@@ -84,8 +84,8 @@ class AsyncHook {
8484
throw new ERR_ASYNC_CALLBACK('hook.destroy');
8585
if (promiseResolve !== undefined && typeof promiseResolve !== 'function')
8686
throw new ERR_ASYNC_CALLBACK('hook.promiseResolve');
87-
if (trackPromises !== undefined && typeof trackPromises !== 'boolean') {
88-
throw new ERR_INVALID_ARG_TYPE('trackPromises', 'boolean', trackPromises);
87+
if (trackPromises !== undefined) {
88+
validateBoolean(trackPromises, 'trackPromises');
8989
}
9090

9191
this[init_symbol] = init;

0 commit comments

Comments
 (0)