Skip to content

Commit bd87fa7

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 d07a270 commit bd87fa7

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
@@ -53,13 +53,7 @@ let domainStorage;
5353

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

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

0 commit comments

Comments
 (0)