Title: Migrating from object.ref()/object.unref() to process.ref()/process.unref() · Issue #53266 · nodejs/node · GitHub
Open Graph Title: Migrating from object.ref()/object.unref() to process.ref()/process.unref() · Issue #53266 · nodejs/node
X Title: Migrating from object.ref()/object.unref() to process.ref()/process.unref() · Issue #53266 · nodejs/node
Description: Node.js has long had a pattern of attaching a ref() and unref() method to various i/o objects that are bound to the event loop. Calling thing.unref() makes it so the thing does not keep the event loop alive. For instance, const i = setIn...
Open Graph Description: Node.js has long had a pattern of attaching a ref() and unref() method to various i/o objects that are bound to the event loop. Calling thing.unref() makes it so the thing does not keep the event l...
X Description: Node.js has long had a pattern of attaching a ref() and unref() method to various i/o objects that are bound to the event loop. Calling thing.unref() makes it so the thing does not keep the event l...
Opengraph URL: https://github.com/nodejs/node/issues/53266
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Migrating from object.ref()/object.unref() to process.ref()/process.unref()","articleBody":"Node.js has long had a pattern of attaching a `ref()` and `unref()` method to various i/o objects that are bound to the event loop. Calling `thing.unref()` makes it so the thing does not keep the event loop alive.\r\n\r\nFor instance,\r\n\r\n```js\r\nconst i = setInterval(() => {}, 1000);\r\ni.unref();\r\n```\r\n\r\nWhile 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)` and `process.ref(thing)` API that would accept multiple different kinds of ref'able types.\r\n\r\n```\r\nconst i = setInterval(() => {}, 1000);\r\nprocess.unref(i);\r\n// etc\r\n```\r\n\r\nA number of API objects that currently have `.ref()`/`.unref()` methods:\r\n\r\n* `dgram.Socket`\r\n* `net.Socket`\r\n* `net.Server`\r\n* `child_process.ChildProcess`\r\n* `child_process.Control`\r\n* `StatWatcher`\r\n* `FSWatcher`\r\n* `MessagePort`\r\n* `Timeout`\r\n* `Interval`\r\n* `Worker`\r\n* `Http2Session`\r\n* `BroadcastChannel`\r\n\r\nThe idea would be to mark the existing object-specific `ref()` and `unref()` methods as legacy and depend on the `process.ref()`/`process.unref()` as the supported mechanism moving forward.\r\n\r\n/cc @mcollina ","author":{"url":"https://github.com/jasnell","@type":"Person","name":"jasnell"},"datePublished":"2024-06-02T19:42:51Z","url":"https://github.com/nodejs/node/issues/53266"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fb22ac59-cac8-264a-b602-73be5084809f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BE0:F5278:1C493EC:25BA865:6AED8A47 |
| html-safe-nonce | 902a895dd156907fb9663a9c21d0c31a2f6f98af147a3a59d81e7647ef773295 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkUwOkY1Mjc4OjFDNDkzRUM6MjVCQTg2NTo2QUVEOEE0NyIsInZpc2l0b3JfaWQiOiI1NDg5MDI4NDQyOTk4Mjc4NzI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 613edccd90279dedd64352abe22a92f7a067471b2982126697517f789a4dd7f5 |
| hovercard-subject-tag | issue:2329832864 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/53266/issue_layout |
| twitter:image | https://opengraph.githubassets.com/63bb52b9b8de70f75d88315f98d1d1bb3f9cb78e906e5979638e5feb4ba27308/nodejs/node/issues/53266 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/63bb52b9b8de70f75d88315f98d1d1bb3f9cb78e906e5979638e5feb4ba27308/nodejs/node/issues/53266 |
| og:image:alt | Node.js has long had a pattern of attaching a ref() and unref() method to various i/o objects that are bound to the event loop. Calling thing.unref() makes it so the thing does not keep the event l... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jasnell |
| hostname | github.com |
| expected-hostname | github.com |
| None | 56fb42677ae87ed3e64410323d67980aa65d0485568a7858f874e7edfc6d1c11 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c9a37e2423ed382cf39f70b5aa4b4858b40a3b0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width