Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
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 <[email protected]>
  • Loading branch information
kovan and claude committed Mar 11, 2026
commit 6f6d86bdf1467a89ef5befcfa29a7d9416557579
9 changes: 3 additions & 6 deletions doc/api/worker_threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -1416,17 +1416,14 @@ port2.postMessage(new Foo());
// Prints: { c: 3 }
```

This limitation extends to many built-in objects, such as the global `URL`
object:
Some built-in objects cannot be cloned at all. For example, posting a
`URL` object throws a `DataCloneError`:

```js
const { port1, port2 } = new MessageChannel();

port1.onmessage = ({ data }) => console.log(data);

port2.postMessage(new URL('https://example.org'));

// Prints: { }
// Throws DataCloneError: Cannot clone object of unsupported type.
```

### `port.hasRef()`
Expand Down