From 4895c2babca17d91de33eeb25d4de83a4ffbe1b8 Mon Sep 17 00:00:00 2001 From: Kit Dallege Date: Wed, 27 May 2026 01:32:14 +0200 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 Signed-off-by: Kit Dallege PR-URL: https://github.com/nodejs/node/pull/62203 Fixes: https://github.com/nodejs/node/issues/60504 Reviewed-By: Luigi Pinca --- 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 8f4b152bc26..720c5640d20 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -1369,17 +1369,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()`