Skip to content

[v24.x] async_hooks: add using scopes to AsyncLocalStorage - #65291

Open
legendecas wants to merge 1 commit into
nodejs:v24.x-stagingfrom
legendecas:backport-61674-to-24
Open

[v24.x] async_hooks: add using scopes to AsyncLocalStorage#65291
legendecas wants to merge 1 commit into
nodejs:v24.x-stagingfrom
legendecas:backport-61674-to-24

Conversation

@legendecas

Copy link
Copy Markdown
Member

Adds support for using scope = storage.withScope(data) to do the equivalent of a storage.run(data, fn) with using syntax. This enables avoiding unnecessary closures.

PR-URL: #61674
Reviewed-By: Anna Henningsen anna@addaleax.net
Reviewed-By: Gerhard Stöbich deb2001-github@yahoo.de
Reviewed-By: Bryan English bryan@bryanenglish.com
Reviewed-By: James M Snell jasnell@gmail.com
Reviewed-By: Chengzhong Wu legendecas@gmail.com

Adds support for using scope = storage.withScope(data) to do
the equivalent of a storage.run(data, fn) with using syntax.
This enables avoiding unnecessary closures.

PR-URL: nodejs#61674
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
@nodejs-github-bot nodejs-github-bot added async_local_storage AsyncLocalStorage needs-ci PRs that need a full CI run. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch. labels Aug 14, 2026
@legendecas legendecas changed the title async_hooks: add using scopes to AsyncLocalStorage [v24.x] async_hooks: add using scopes to AsyncLocalStorage Aug 14, 2026
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.31%. Comparing base (9e39360) to head (2444f97).

Additional details and impacted files
@@              Coverage Diff               @@
##           v24.x-staging   #65291   +/-   ##
==============================================
  Coverage          90.31%   90.31%           
==============================================
  Files                711      712    +1     
  Lines             228425   228468   +43     
  Branches           43160    43174   +14     
==============================================
+ Hits              206293   206342   +49     
+ Misses             14090    14082    -8     
- Partials            8042     8044    +2     
Files with missing lines Coverage Δ
...nternal/async_local_storage/async_context_frame.js 100.00% <100.00%> (ø)
lib/internal/async_local_storage/async_hooks.js 98.20% <100.00%> (+0.06%) ⬆️
lib/internal/async_local_storage/run_scope.js 100.00% <100.00%> (ø)

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

async_local_storage AsyncLocalStorage needs-ci PRs that need a full CI run. v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants