diff options
author | Darshan Sen <raisinten@gmail.com> | 2022-05-02 07:39:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-02 07:39:39 +0300 |
commit | 1d8a320a04d75b2143be0bc97b10dfcd9e64defa (patch) | |
tree | acdd41199780556110b9d1a6591ec60754193cc3 /doc/api/worker_threads.md | |
parent | 7a53696c8aec068d89ad2cf017c74683b79525a0 (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.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 00b790e6e88..dc37b6d18ad 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -767,6 +767,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 |