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

lib: lazy load v8 in error-serdes #26689

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion lib/internal/error-serdes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const Buffer = require('buffer').Buffer;
const { serialize, deserialize } = require('v8');
const {
SafeSet,
Object,
Expand Down Expand Up @@ -84,7 +83,9 @@ function lazyUtil() {
return util;
}

let serialize;
function serializeError(error) {
if (!serialize) serialize = require('v8').serialize;
try {
if (typeof error === 'object' &&
ObjectPrototypeToString(error) === '[object Error]') {
Expand All @@ -109,7 +110,9 @@ function serializeError(error) {
Buffer.from(lazyUtil().inspect(error), 'utf8')]);
}

let deserialize;
function deserializeError(error) {
if (!deserialize) deserialize = require('v8').deserialize;
switch (error[0]) {
case kSerializedError:
const { constructor, properties } = deserialize(error.subarray(1));
Expand Down
7 changes: 0 additions & 7 deletions test/parallel/test-bootstrap-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,8 @@ if (common.isMainThread) {
expectedModules.add('NativeModule internal/process/main_thread_only');
expectedModules.add('NativeModule internal/process/stdio');
} else {
expectedModules.add('Internal Binding heap_utils');
expectedModules.add('Internal Binding messaging');
expectedModules.add('Internal Binding serdes');
expectedModules.add('Internal Binding stream_wrap');
expectedModules.add('Internal Binding symbols');
expectedModules.add('Internal Binding uv');
expectedModules.add('Internal Binding v8');
expectedModules.add('Internal Binding worker');
expectedModules.add('NativeModule _stream_duplex');
expectedModules.add('NativeModule _stream_passthrough');
Expand All @@ -86,7 +81,6 @@ if (common.isMainThread) {
expectedModules.add('NativeModule _stream_writable');
expectedModules.add('NativeModule internal/error-serdes');
expectedModules.add('NativeModule internal/process/worker_thread_only');
expectedModules.add('NativeModule internal/stream_base_commons');
expectedModules.add('NativeModule internal/streams/buffer_list');
expectedModules.add('NativeModule internal/streams/destroy');
expectedModules.add('NativeModule internal/streams/end-of-stream');
Expand All @@ -97,7 +91,6 @@ if (common.isMainThread) {
expectedModules.add('NativeModule internal/worker/io');
expectedModules.add('NativeModule module');
expectedModules.add('NativeModule stream');
expectedModules.add('NativeModule v8');
expectedModules.add('NativeModule worker_threads');
}

Expand Down