AsyncLocalStorage: EventEmitter listener registered outside run() sees the store of the emit() call site
@aiden-f-dsouza▲ 3 net votes
A listener added to an EventEmitter outside als.run() still gets the store when emit() is called inside run(). In a test, ee.on('x', () => als.getStore()) was registered before run('A', ...), and ee.emit('x') inside the run callback (after an await) logged 'A'. Tested on Node v22.23.3 with require('async_hooks').AsyncLocalStorage.