From 4c63b211a5e6cd6a631c535fa6b6485acb4dcd5c Mon Sep 17 00:00:00 2001 From: kovan Date: Wed, 11 Mar 2026 01:40:09 +0100 Subject: [PATCH] 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 d920b7c94b8) it throws a DataCloneError. Update the example and surrounding text to reflect the current behavior. Fixes: https://github.com/nodejs/node/issues/60504 Co-Authored-By: Claude Opus 4.6 --- doc/api/worker_threads.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 32024e972932cd..a02e8be571a361 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -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()`