Title: Revisit the AsyncLocalStorage onPropagate option · Issue #46374 · nodejs/node · GitHub
Open Graph Title: Revisit the AsyncLocalStorage onPropagate option · Issue #46374 · nodejs/node
X Title: Revisit the AsyncLocalStorage onPropagate option · Issue #46374 · nodejs/node
Description: The onPropagate option was landed as experimental in v19.2... I'd like to propose that we revisit that and take a different approach. https://nodejs.org/dist/latest-v19.x/docs/api/async_context.html#new-asynclocalstorageoptions As backgr...
Open Graph Description: The onPropagate option was landed as experimental in v19.2... I'd like to propose that we revisit that and take a different approach. https://nodejs.org/dist/latest-v19.x/docs/api/async_context.htm...
X Description: The onPropagate option was landed as experimental in v19.2... I'd like to propose that we revisit that and take a different approach. https://nodejs.org/dist/latest-v19.x/docs/api/async_context...
Opengraph URL: https://github.com/nodejs/node/issues/46374
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Revisit the AsyncLocalStorage onPropagate option","articleBody":"The `onPropagate` option was landed as experimental in v19.2... I'd like to propose that we revisit that and take a different approach.\r\n\r\nhttps://nodejs.org/dist/latest-v19.x/docs/api/async_context.html#new-asynclocalstorageoptions\r\n\r\nAs background, `onPropagate` attaches a callback function to the `AsyncLocalStorage` instance that is invoked whenever a new `AsyncResource` is created. This is problematic primarily because it incurs a significant additional performance overhead and assumes a model that is based on the underlying async_hooks API model (which I think there's consensus we want to move away from https://github.com/nodejs/node/issues/46265).\r\n\r\nAlternatively, I'd like to propose a \"tag' model like in the following example:\r\n\r\n```js\r\n// Defines the ALS instance such that a matching tag must be\r\n// passed in to `getStore()` to successfully retrieve the store.\r\nconst als = new AsyncLocalStorage({ tag: 'foo' });\r\n\r\nconsole.log(als.run(123, () => als.getStore('foo')); // 123\r\nconsole.log(als.run(321, () => als.getStore()); // undefined, doesn't match\r\nconsole.log(als.run(321, () => als.getStore('bar')); // undefined, doesn't match\r\n```\r\n\r\nThe `tag` here effectively becomes a component of the storage key. This is much more efficient design that will not incur a significant additional performance penalty.\r\n\r\n/cc @legendecas @littledan @nodejs/async_hooks ","author":{"url":"https://github.com/jasnell","@type":"Person","name":"jasnell"},"datePublished":"2023-01-26T19:09:49Z","url":"https://github.com/nodejs/node/issues/46374"}
| 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:cdc5fb51-f64e-909c-30ea-7fee46a7421b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E20C:284A23:E1780:133BBB:6AED352F |
| html-safe-nonce | 1e99ea0172476183c4a8ac69ac6df53c96c05f4655c67f2f386f2db87fa8fee2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjBDOjI4NEEyMzpFMTc4MDoxMzNCQkI6NkFFRDM1MkYiLCJ2aXNpdG9yX2lkIjoiMjA3MDYxMDk1OTMzMDUyMjQxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ccf70fd98cccfb66af5a76fc7927066eb50cc4d4bf5ff6fa9cf4115da94df8b1 |
| hovercard-subject-tag | issue:1558632685 |
| 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/46374/issue_layout |
| twitter:image | https://opengraph.githubassets.com/886b917cb9ba6fa4f549b8408e8d9548043945f754285285e297f7a22002f3fc/nodejs/node/issues/46374 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/886b917cb9ba6fa4f549b8408e8d9548043945f754285285e297f7a22002f3fc/nodejs/node/issues/46374 |
| og:image:alt | The onPropagate option was landed as experimental in v19.2... I'd like to propose that we revisit that and take a different approach. https://nodejs.org/dist/latest-v19.x/docs/api/async_context.htm... |
| 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 | 26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184 |
| 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 | c629ad99c254d306375fc8354d04321c2c362236 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width