Uh oh!
There was an error while loading. Please reload this page.
doc: stabilize AsyncLocalStorage methods - #58019
Conversation
Mark AsyncLocalStorage#enterWith and AsyncLocalStorage#disable as stable
Flarna
commented
Apr 25, 2025
As far as I remember it was not marked as stable for following reasons:
Having these APIs stable and getting native JS support for |
| --> | ||
| > Stability: 1 - Experimental | ||
| > Stability: 2 - Stable |
There was a problem hiding this comment.
I think we should mention the version when it was moved from experimental to stable in the YAML section above.
see e.g. AsyncLocalStorage.snapshot() as reference.
mcollina
commented
Apr 25, 2025
We can't remove them either because they are needed for the instrumentation/apm use case as well as many frameworks. You can see examples in: nodejs/standards-positions#2 (comment). We should mark those as stable, or remove them entirely if an alternative can be identified. |
vdeturckheim
commented
Apr 25, 2025
Flarna
commented
Apr 25, 2025
Sorry, my intention was not to block this. I was in favor of a simple I guess the best extension to What I still don't like is the name - Another question: Any reason why While writing this I remembered that |
No worries, I did not read it this way, also, I opened this PR to re-open the discussion! I like the idea of using cc @legendecas |
Comparing to asyncfunctionfoo(){als.enterWith(newValue);await0;}If It's fair to say that an experimental API has been used a lot and it should be promote to stable, but it should also be documented in which case it will break as caveats. That's been said, I think |
I'm not against graduating these to stable but I would suggest perhaps moving these APIs immediately to the And as a side note, we likely need to align |
mcollina
commented
Apr 27, 2025
I would not mark enterWith() as legacy as long as there isn't a viable alternative. |
This fixes the leak behavior when using `enterWith` when no `AsyncLocalStorage`s were enabled inside a promise. PR-URL: #58029Fixes: #53037 Refs: #58019 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
vdeturckheim
commented
Apr 30, 2025
I'll wait for |
This fixes the leak behavior when using `enterWith` when no `AsyncLocalStorage`s were enabled inside a promise. PR-URL: #58029Fixes: #53037 Refs: #58019 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This fixes the leak behavior when using `enterWith` when no `AsyncLocalStorage`s were enabled inside a promise. PR-URL: #58029Fixes: #53037 Refs: #58019 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
vdeturckheim
commented
May 7, 2025
I just pushed a draft commit showing how we could use explicit ressource management With this commit, the code: import{AsyncLocalStorage}from'async_hooks';import{setTimeout}from'timers/promises';constctx=newAsyncLocalStorage()constf1=asyncfunction(){usingc=ctx.unNamedMethod({f: 1});console.log(ctx.getStore());awaitsetTimeout(5000);console.log(ctx.getStore());}constf2=asyncfunction(){usingc=ctx.unNamedMethod({f: 2});console.log(ctx.getStore());awaitsetTimeout(2000);console.log(ctx.getStore());}f1();f2();displays |
closing in favor of #58104 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #58019 +/- ##
==========================================
- Coverage 90.12% 90.12% -0.01%
==========================================
Files 629 629 Lines 186628 186650 +22 Branches 36622 36623 +1 ==========================================
+ Hits 168206 168219 +13 - Misses 11216 11233 +17 + Partials 7206 7198 -8
🚀 New features to boost your workflow:
|
Mark AsyncLocalStorage#enterWith and AsyncLocalStorage#disable as stable
Following discussions with @mcollina , I don't remember fully why these two methods are now stable.
They might be confusing for the end user to know which context they are in but now that async context tracking is more well known, I don't think this is so much of a big problem?