Skip to content

Commit 9a5c149

Browse files
dnluptargos
authored andcommitted
errors: remove usage of require('util')
Remove internal usage of `require('util').inspect`. PR-URL: #26781 Refs: #26546 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
1 parent 14cc4f2 commit 9a5c149

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/internal/error-serdes.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ function GetName(object) {
7777
return desc && desc.value;
7878
}
7979

80-
let util;
81-
function lazyUtil() {
82-
if (!util)
83-
util = require('util');
84-
return util;
80+
let internalUtilInspect;
81+
function inspect(...args) {
82+
if (!internalUtilInspect) {
83+
internalUtilInspect = require('internal/util/inspect');
84+
}
85+
return internalUtilInspect.inspect(...args);
8586
}
8687

8788
function serializeError(error) {
@@ -106,7 +107,7 @@ function serializeError(error) {
106107
return Buffer.concat([Buffer.from([kSerializedObject]), serialized]);
107108
} catch {}
108109
return Buffer.concat([Buffer.from([kInspectedError]),
109-
Buffer.from(lazyUtil().inspect(error), 'utf8')]);
110+
Buffer.from(inspect(error), 'utf8')]);
110111
}
111112

112113
function deserializeError(error) {

0 commit comments

Comments
 (0)