From 3ce515c642c280dd492f897e3f35e89902a95c3c Mon Sep 17 00:00:00 2001 From: Soul Lee Date: Sat, 25 Jul 2026 15:11:34 +0900 Subject: [PATCH] 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 --- lib/async_hooks.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/async_hooks.js b/lib/async_hooks.js index 74429cf8bc12..31a390dfc912 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -19,13 +19,13 @@ const { ERR_ASYNC_RESOURCE_DOMAIN_REMOVED, ERR_ASYNC_TYPE, ERR_INVALID_ASYNC_ID, - ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, } = require('internal/errors').codes; const { kEmptyObject, } = require('internal/util'); const { + validateBoolean, validateFunction, validateString, } = require('internal/validators'); @@ -85,8 +85,8 @@ class AsyncHook { throw new ERR_ASYNC_CALLBACK('hook.destroy'); if (promiseResolve !== undefined && typeof promiseResolve !== 'function') throw new ERR_ASYNC_CALLBACK('hook.promiseResolve'); - if (trackPromises !== undefined && typeof trackPromises !== 'boolean') { - throw new ERR_INVALID_ARG_TYPE('trackPromises', 'boolean', trackPromises); + if (trackPromises !== undefined) { + validateBoolean(trackPromises, 'trackPromises'); } this[init_symbol] = init;