-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
domain: port to AsyncLocalStorage #61095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61095 +/- ##
==========================================
- Coverage 88.53% 88.51% -0.03%
==========================================
Files 703 703
Lines 208538 208662 +124
Branches 40224 40235 +11
==========================================
+ Hits 184629 184696 +67
- Misses 15912 15975 +63
+ Partials 7997 7991 -6
🚀 New features to boost your workflow:
|
8a8cf7f to
b307f20
Compare
Port the domain module from createHook (async_hooks) to AsyncLocalStorage using the AsyncContextFrame-based implementation. Key changes: - Use AsyncLocalStorage for domain context propagation instead of async_hooks.createHook() - Lazy initialization that triggers AsyncContextFrame prototype swap on first domain use - Use enterWith instead of ALS.run() so domain context is NOT automatically restored on exception - this matches the original domain.run() behavior where exit() only runs on success - Add ERR_ASYNC_RESOURCE_DOMAIN_REMOVED error for AsyncResource.domain - Update DEP0097 to End-of-Life status - Remove tests that relied on the removed MakeCallback domain property The domain module now uses the AsyncContextFrame version of AsyncLocalStorage directly for proper context propagation across async boundaries.
b307f20 to
1d24947
Compare
Flarna
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit that I do not fully understand domains so take my review with a grain of salt.
Remove the useDomainTrampoline function and related domain_cb variable that are no longer used after domain was ported to AsyncLocalStorage.
The test no longer tests async-id map leaks. Rename to reflect its actual purpose: verifying that accessing domain property on AsyncResource throws ERR_ASYNC_RESOURCE_DOMAIN_REMOVED.
Use require('async_hooks').AsyncLocalStorage instead of directly
importing internal modules. This allows proper auto-selection of
the ALS implementation based on --async-context-frame flag.
Extract common domain context setup/teardown logic into a single runInDomain helper function, reducing code duplication.
When an EventEmitter emits 'error' and the domain's error handler throws, the exception should propagate to the parent domain, not recursively call the same domain's error handler. The bug was that currentDomain/currentStack were not updated when temporarily switching to the parent domain context during error emission. Since domainExceptionHandler checks currentDomain first, exceptions would incorrectly route back to the same domain. Fixes by updating currentDomain/currentStack alongside the ALS store.
Port the domain module from createHook (async_hooks) to AsyncLocalStorage using the AsyncContextFrame-based implementation.
Key changes:
The domain module now uses the AsyncContextFrame version of AsyncLocalStorage directly for proper context propagation across async boundaries.