Skip to content

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

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

[v24.x backport] async_hooks: add using scopes to AsyncLocalStorage#65291
legendecas wants to merge 2 commits 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 (b481c29).
⚠️ Report is 2 commits behind head on v24.x-staging.

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    43169    +9     
==============================================
+ Hits              206293   206338   +45     
+ Misses             14090    14083    -7     
- Partials            8042     8047    +5     
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.

@aduh95

aduh95 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Error: Unrecognized type: 'RunScope' in 'file:///home/runner/work/node/node/tools/doc/type-parser.mjs'. in make test-doc to address

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 19, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 19, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@aduh95 aduh95 changed the title [v24.x] async_hooks: add using scopes to AsyncLocalStorage [v24.x backport] async_hooks: add using scopes to AsyncLocalStorage Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

async_local_storage AsyncLocalStorage author ready PRs that have at least one approval, no pending requests for changes, and a CI started. 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.

4 participants