mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
v8: inspect unserializable objects
This would otherwise sometimes just print relatively useless information about the value in question, such as `[object Object]`. PR-URL: https://github.com/nodejs/node/pull/30167 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com>
This commit is contained in:
parent
d855904ef6
commit
afd29c9502
@ -24,6 +24,7 @@ const {
|
|||||||
} = internalBinding('serdes');
|
} = internalBinding('serdes');
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const { copy } = internalBinding('buffer');
|
const { copy } = internalBinding('buffer');
|
||||||
|
const { inspect } = require('internal/util/inspect');
|
||||||
const { FastBuffer } = require('internal/buffer');
|
const { FastBuffer } = require('internal/buffer');
|
||||||
const { getValidatedPath } = require('internal/fs/utils');
|
const { getValidatedPath } = require('internal/fs/utils');
|
||||||
const { toNamespacedPath } = require('path');
|
const { toNamespacedPath } = require('path');
|
||||||
@ -242,7 +243,8 @@ class DefaultSerializer extends Serializer {
|
|||||||
i = arrayBufferViewTypeToIndex.get(tag);
|
i = arrayBufferViewTypeToIndex.get(tag);
|
||||||
|
|
||||||
if (i === undefined) {
|
if (i === undefined) {
|
||||||
throw new this._getDataCloneError(`Unknown host object type: ${tag}`);
|
throw new this._getDataCloneError(
|
||||||
|
`Unserializable host object: ${inspect(abView)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.writeUint32(i);
|
this.writeUint32(i);
|
||||||
|
@ -156,8 +156,10 @@ const deserializerTypeError =
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
assert.throws(() => v8.serialize(hostObject),
|
assert.throws(() => v8.serialize(hostObject), {
|
||||||
/^Error: Unknown host object type: \[object .*\]$/);
|
constructor: Error,
|
||||||
|
message: 'Unserializable host object: JSStream {}'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user