Skip to content

Commit 553c876

Browse files
dnlupdanbev
authored andcommitted
errors: remove usage of require('util')
Remove internal usage of `require('util').inspect`. PR-URL: nodejs#26781 Refs: nodejs#26546 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
1 parent 136c805 commit 553c876

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/internal/error-serdes.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ function GetName(object) {
7676
return desc && desc.value;
7777
}
7878

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

8687
let serialize;
@@ -107,7 +108,7 @@ function serializeError(error) {
107108
return Buffer.concat([Buffer.from([kSerializedObject]), serialized]);
108109
} catch {}
109110
return Buffer.concat([Buffer.from([kInspectedError]),
110-
Buffer.from(lazyUtil().inspect(error), 'utf8')]);
111+
Buffer.from(inspect(error), 'utf8')]);
111112
}
112113

113114
let deserialize;

0 commit comments

Comments
 (0)