Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarshan Sen <raisinten@gmail.com>2022-05-02 07:39:39 +0300
committerMichaƫl Zasso <targos@protonmail.com>2022-05-02 15:39:33 +0300
commitbf9240ae8c82f2b275109528eff4ffa43207fde1 (patch)
treebf8ea70f6457e5d5cc2f94f8901bc9a9337088cb /doc/api/worker_threads.md
parent1e7479d34c678e3f169f4a95f337d6cc9e4d346b (diff)
worker: add hasRef() to MessagePort
Since we were removing the hasRef() method before exposing the MessagePort object, the only way of knowing if the handle was keeping the event loop active was to parse the string returned by util.inspect(port), which is inconvenient and inconsistent with most of the other async resources. So this change stops removing hasRef() from the MessagePort prototype. The reason why this is also being documented is that while reporting active resources, async_hooks returns the same MessagePort object as the one that is accessible by users. Refs: https://github.com/nodejs/node/issues/42091#issuecomment-1104793189 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/42849 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'doc/api/worker_threads.md')
-rw-r--r--doc/api/worker_threads.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md
index bbb35aa3ca5..0db2e620f6f 100644
--- a/doc/api/worker_threads.md
+++ b/doc/api/worker_threads.md
@@ -763,6 +763,18 @@ port2.postMessage(new URL('https://example.org'));
// Prints: { }
```
+### `port.hasRef()`
+
+<!-- YAML
+added: REPLACEME
+-->
+
+> Stability: 1 - Experimental
+
+* Returns: {boolean}
+
+If true, the `MessagePort` object will keep the Node.js event loop active.
+
### `port.ref()`
<!-- YAML