Skip to content

Commit c8a7b16

Browse files
committed
domain: use public AsyncLocalStorage API
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.
1 parent d10bca6 commit c8a7b16

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

lib/domain.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,7 @@ let domainStorage;
5050

5151
function initDomainStorage() {
5252
if (domainStorage === undefined) {
53-
// Import AsyncContextFrame and trigger enabled check to ensure prototype swap
54-
const AsyncContextFrame = require('internal/async_context_frame');
55-
// eslint-disable-next-line no-unused-expressions
56-
AsyncContextFrame.enabled; // Triggers prototype swap from inactive to active
57-
58-
// Import the async_context_frame-based ALS directly to avoid circular deps
59-
const AsyncLocalStorage = require('internal/async_local_storage/async_context_frame');
53+
const { AsyncLocalStorage } = require('async_hooks');
6054

6155
// Single AsyncLocalStorage instance for all domain context
6256
// Store structure: { domain: Domain | null, stack: Domain[] }

0 commit comments

Comments
 (0)