async_hooks: enable AsyncLocalStorage once constructed#58029
Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom Apr 27, 2025
Merged
async_hooks: enable AsyncLocalStorage once constructed#58029nodejs-github-bot merged 1 commit intonodejs:mainfrom
nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
This fixes the leak behavior when using `enterWith` when no `AsyncLocalStorage`s were enabled inside a promise.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #58029 +/- ##
==========================================
- Coverage 90.27% 90.27% -0.01%
==========================================
Files 630 630
Lines 186159 186161 +2
Branches 36473 36476 +3
==========================================
- Hits 168053 168048 -5
+ Misses 10976 10974 -2
- Partials 7130 7139 +9
🚀 New features to boost your workflow:
|
Flarna
approved these changes
Apr 26, 2025
Collaborator
jasnell
approved these changes
Apr 26, 2025
Member
|
Does this only reproduce with the async_hooks version of AsyncLocalStorage? |
Member
Author
Yes. |
Collaborator
|
Landed in 8e7ae60 |
Member
|
I'm adding a backing-for-lts comment as we should evaluate if it has real-life breakage before backporting |
RafaelGSS
pushed a commit
that referenced
this pull request
May 1, 2025
This fixes the leak behavior when using `enterWith` when no `AsyncLocalStorage`s were enabled inside a promise. PR-URL: #58029 Fixes: #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>
RafaelGSS
pushed a commit
that referenced
this pull request
May 2, 2025
This fixes the leak behavior when using `enterWith` when no `AsyncLocalStorage`s were enabled inside a promise. PR-URL: #58029 Fixes: #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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the leak behavior when using
enterWithwhen noAsyncLocalStorages were enabled inside a promise. With thischange, the following code snippets will behave the same:
On the performance side, given that an
AsyncLocalStorageis constructed, we should assume that it will be used and prefer correctness over lazy-initialization optimization.Fixes: #53037
Refs: #58019
/cc @nodejs/diagnostics