11'use strict' ;
22
33const {
4- ObjectSetPrototypeOf,
54 SafeMap,
65} = primordials ;
76
@@ -10,11 +9,10 @@ const {
109 setContinuationPreservedEmbedderData,
1110} = internalBinding ( 'async_context_frame' ) ;
1211
13- let enabled_ ;
14-
15- class ActiveAsyncContextFrame extends SafeMap {
16- static get enabled ( ) {
17- return true ;
12+ class AsyncContextFrame extends SafeMap {
13+ constructor ( store , data ) {
14+ super ( AsyncContextFrame . current ( ) ) ;
15+ this . set ( store , data ) ;
1816 }
1917
2018 static current ( ) {
@@ -35,39 +33,6 @@ class ActiveAsyncContextFrame extends SafeMap {
3533 const frame = this . current ( ) ;
3634 frame ?. disable ( store ) ;
3735 }
38- }
39-
40- function checkEnabled ( ) {
41- const enabled = require ( 'internal/options' )
42- . getOptionValue ( '--async-context-frame' ) ;
43-
44- // If enabled, swap to active prototype so we don't need to check status
45- // on every interaction with the async context frame.
46- if ( enabled ) {
47- // eslint-disable-next-line no-use-before-define
48- ObjectSetPrototypeOf ( AsyncContextFrame , ActiveAsyncContextFrame ) ;
49- }
50-
51- return enabled ;
52- }
53-
54- class InactiveAsyncContextFrame extends SafeMap {
55- static get enabled ( ) {
56- enabled_ ??= checkEnabled ( ) ;
57- return enabled_ ;
58- }
59-
60- static current ( ) { }
61- static set ( frame ) { }
62- static exchange ( frame ) { }
63- static disable ( store ) { }
64- }
65-
66- class AsyncContextFrame extends InactiveAsyncContextFrame {
67- constructor ( store , data ) {
68- super ( AsyncContextFrame . current ( ) ) ;
69- this . set ( store , data ) ;
70- }
7136
7237 disable ( store ) {
7338 this . delete ( store ) ;
0 commit comments