src: throw DOMException on cloning non-serializable objects

Instead of TypeError, throwing DOMException in accordance to the HTML
structured serialize algorithms.

PR-URL: https://github.com/nodejs/node/pull/47839
Fixes: https://github.com/nodejs/node/issues/40841
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
Chengzhong Wu authored and GitHub committed 2023-10-08 12:51:01 +00:00
1 parent e43bf4c31d
commit d920b7c94b
7 files changed
+61 -38

No files matched your search

+36 -23
View File
@@ -2084,12 +2084,6 @@ urlSearchParams.has.call(buf, 'foo');
// Throws a TypeError with code 'ERR_INVALID_THIS'
```
<a id="ERR_INVALID_TRANSFER_OBJECT"></a>
### `ERR_INVALID_TRANSFER_OBJECT`
An invalid transfer object was passed to `postMessage()`.
<a id="ERR_INVALID_TUPLE"></a>
### `ERR_INVALID_TUPLE`
@@ -2287,23 +2281,6 @@ The V8 platform used by this instance of Node.js does not support creating
Workers. This is caused by lack of embedder support for Workers. In particular,
this error will not occur with standard builds of Node.js.
<a id="ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST"></a>
### `ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST`
<!-- YAML
added: v15.0.0
-->
An object that needs to be explicitly listed in the `transferList` argument
is in the object passed to a [`postMessage()`][] call, but is not provided
in the `transferList` for that call. Usually, this is a `MessagePort`.
In Node.js versions prior to v15.0.0, the error code being used here was
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`][]. However, the set of
transferable object types has been expanded to cover more types than
`MessagePort`.
<a id="ERR_MODULE_NOT_FOUND"></a>
### `ERR_MODULE_NOT_FOUND`
@@ -3300,6 +3277,20 @@ removed: v15.0.0
An invalid or unknown file encoding was passed.
<a id="ERR_INVALID_TRANSFER_OBJECT"></a>
### `ERR_INVALID_TRANSFER_OBJECT`
<!-- YAML
removed: REPLACEME
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/47839
description: A `DOMException` is thrown instead.
-->
An invalid transfer object was passed to `postMessage()`.
<a id="ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST"></a>
### `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`
@@ -3312,6 +3303,28 @@ This error code was replaced by [`ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST`][]
in Node.js v15.0.0, because it is no longer accurate as other types of
transferable objects also exist now.
<a id="ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST"></a>
### `ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST`
<!-- YAML
added: v15.0.0
removed: REPLACEME
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/47839
description: A `DOMException` is thrown instead.
-->
An object that needs to be explicitly listed in the `transferList` argument
is in the object passed to a [`postMessage()`][] call, but is not provided
in the `transferList` for that call. Usually, this is a `MessagePort`.
In Node.js versions prior to v15.0.0, the error code being used here was
[`ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST`][]. However, the set of
transferable object types has been expanded to cover more types than
`MessagePort`.
<a id="ERR_NAPI_CONS_PROTOTYPE_OBJECT"></a>
### `ERR_NAPI_CONS_PROTOTYPE_OBJECT`