Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors: remove usage of require('util') #26781

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/internal/error-serdes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved

let serialize;
Expand All @@ -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;
Expand Down