Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7da2a44

Browse filesBrowse files
kovanclaude
authored andcommitted
doc: fix URL postMessage example in worker_threads
The example claimed that posting a URL object via MessageChannel would print an empty object, but since v21.0.0 (commit d920b7c) it throws a DataCloneError. Update the example and surrounding text to reflect the current behavior. Fixes: #60504 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Kit Dallege <xaum.io@gmail.com> PR-URL: #62203 Fixes: #60504 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 2e4a0d0 commit 7da2a44
Copy full SHA for 7da2a44

1 file changed

+3-6Lines changed: 3 additions & 6 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/worker_threads.md‎

Copy file name to clipboardExpand all lines: doc/api/worker_threads.md
+3-6Lines changed: 3 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1412,17 +1412,14 @@ port2.postMessage(new Foo());
14121412
// Prints: { c: 3 }
14131413
```
14141414
1415-
This limitation extends to many built-in objects, such as the global `URL`
1416-
object:
1415+
Some built-in objects cannot be cloned at all. For example, posting a
1416+
`URL` object throws a `DataCloneError`:
14171417
14181418
```js
14191419
const { port1, port2 } = new MessageChannel();
14201420

1421-
port1.onmessage = ({ data }) => console.log(data);
1422-
14231421
port2.postMessage(new URL('https://example.org'));
1424-
1425-
// Prints: { }
1422+
// Throws DataCloneError: Cannot clone object of unsupported type.
14261423
```
14271424
14281425
### `port.hasRef()`

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.