-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrating from object.ref()/object.unref() to process.ref()/process.unref() #53266
Comments
+1 this makes sense to do from the outside |
+1 for me. However we are never going to be able to remove the previous methods either (unfortunately), as they will break everybody. |
+1 |
Ok, given the thumbs up on it, I'll start working this up |
Yeah, I know. My plan would be to keep those existing methods in place but change them to use the new mechanism under the covers. The public APIs would then be marked as legacy with a note to use the new |
The `process.ref(...)` and `process.unref(...)` methods are intended to replace the use of `ref()` and `unref()` methods defined directly on individual API objects. The existing `ref()` and `unref()` methods will be marked as legacy and won't be removed but new APIs should use `process.ref()` and `process.unref()` instead. Refs: nodejs#53266
The `process.ref(...)` and `process.unref(...)` methods are intended to replace the use of `ref()` and `unref()` methods defined directly on individual API objects. The existing `ref()` and `unref()` methods will be marked as legacy and won't be removed but new APIs should use `process.ref()` and `process.unref()` instead. Refs: #53266 PR-URL: #56400 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
The `process.ref(...)` and `process.unref(...)` methods are intended to replace the use of `ref()` and `unref()` methods defined directly on individual API objects. The existing `ref()` and `unref()` methods will be marked as legacy and won't be removed but new APIs should use `process.ref()` and `process.unref()` instead. Refs: #53266 PR-URL: #56400 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Node.js has long had a pattern of attaching a
ref()
andunref()
method to various i/o objects that are bound to the event loop. Callingthing.unref()
makes it so the thing does not keep the event loop alive.For instance,
While this has worked effectively for Node.js specific APIs, it's rather cumbersome with web platform standard APIs. I'd like to propose a change: Introduce new
process.unref(thing)
andprocess.ref(thing)
API that would accept multiple different kinds of ref'able types.A number of API objects that currently have
.ref()
/.unref()
methods:dgram.Socket
net.Socket
net.Server
child_process.ChildProcess
child_process.Control
StatWatcher
FSWatcher
MessagePort
Timeout
Interval
Worker
Http2Session
BroadcastChannel
The idea would be to mark the existing object-specific
ref()
andunref()
methods as legacy and depend on theprocess.ref()
/process.unref()
as the supported mechanism moving forward./cc @mcollina
The text was updated successfully, but these errors were encountered: