Skip to content
Permalink
Browse files

v8: inspect unserializable objects

This would otherwise sometimes just print relatively useless
information about the value in question, such as `[object Object]`.

PR-URL: #30167
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: David Carlier <devnexen@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed Oct 29, 2019
1 parent 74dd216 commit 2994976ec786c00365333d6fb1b797b995bb5384
Showing with 7 additions and 3 deletions.
  1. +3 −1 lib/v8.js
  2. +4 −2 test/parallel/test-v8-serdes.js
@@ -24,6 +24,7 @@ const {
} = internalBinding('serdes');
const assert = require('internal/assert');
const { copy } = internalBinding('buffer');
const { inspect } = require('internal/util/inspect');
const { FastBuffer } = require('internal/buffer');
const { getValidatedPath } = require('internal/fs/utils');
const { toNamespacedPath } = require('path');
@@ -242,7 +243,8 @@ class DefaultSerializer extends Serializer {
i = arrayBufferViewTypeToIndex.get(tag);

if (i === undefined) {
throw new this._getDataCloneError(`Unknown host object type: ${tag}`);
throw new this._getDataCloneError(
`Unserializable host object: ${inspect(abView)}`);
}
}
this.writeUint32(i);
@@ -156,8 +156,10 @@ const deserializerTypeError =
}

{
assert.throws(() => v8.serialize(hostObject),
/^Error: Unknown host object type: \[object .*\]$/);
assert.throws(() => v8.serialize(hostObject), {
constructor: Error,
message: 'Unserializable host object: JSStream {}'
});
}

{

0 comments on commit 2994976

Please sign in to comment.
You can’t perform that action at this time.