File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,20 +159,29 @@ const { AsyncLocalStorage } = require('async_hooks');
159159 const key = Symbol ( 'store' ) ;
160160 const ch = channel ( 'test-suppression-store' ) ;
161161 const als = new AsyncLocalStorage ( ) ;
162+ const normalAls = new AsyncLocalStorage ( ) ;
162163
164+ // Normal store — should always be entered
165+ ch . bindStore ( normalAls , common . mustCall ( ( data ) => data ) ) ;
166+
167+ // Bypass store — should be skipped inside suppressed()
168+ ch . bindStore ( als , common . mustNotCall ( ) , { subscriberId : key } ) ;
169+
170+ // Normal subscriber — verifies normal store entered, bypass store skipped
163171 const handler = common . mustCall ( ( ) => {
172+ assert . strictEqual ( normalAls . getStore ( ) ?. entered , true ) ;
164173 assert . strictEqual ( als . getStore ( ) , undefined ) ;
165174 } ) ;
166175
167176 ch . subscribe ( handler ) ;
168- ch . bindStore ( als , common . mustNotCall ( ) , { subscriberId : key } ) ;
169177
170178 suppressed ( key , common . mustCall ( ( ) => {
171- ch . publish ( { } ) ;
179+ ch . publish ( { entered : true } ) ;
172180 } ) ) ;
173181
174182 ch . unsubscribe ( handler ) ;
175183 ch . unbindStore ( als ) ;
184+ ch . unbindStore ( normalAls ) ;
176185}
177186
178187// Test 9: Wrong type for subscriberId throws ERR_INVALID_ARG_TYPE
You can’t perform that action at this time.
0 commit comments