diff --git a/lib/internal/error-serdes.js b/lib/internal/error-serdes.js index 895133bc8f79cf..b907842c3896ff 100644 --- a/lib/internal/error-serdes.js +++ b/lib/internal/error-serdes.js @@ -76,11 +76,12 @@ function GetName(object) { return desc && desc.value; } -let util; -function lazyUtil() { - if (!util) - util = require('util'); - return util; +let internalUtilInspect; +function inspect(...args) { + if (!internalUtilInspect) { + internalUtilInspect = require('internal/util/inspect'); + } + return internalUtilInspect.inspect(...args); } let serialize; @@ -107,7 +108,7 @@ function serializeError(error) { return Buffer.concat([Buffer.from([kSerializedObject]), serialized]); } catch {} return Buffer.concat([Buffer.from([kInspectedError]), - Buffer.from(lazyUtil().inspect(error), 'utf8')]); + Buffer.from(inspect(error), 'utf8')]); } let deserialize;