Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardNodeJSasync_hooks execution contextSingle-choice MCQ

async_hooks tracks the asynchronous execution context that AsyncLocalStorage relies on. Considering how the async-context graph is built, what does this code print for the two reads of als.getStore()?

const { AsyncLocalStorage } = require('async_hooks'); const als = new AsyncLocalStorage(); als.run('ctx', () => { setTimeout(() => { console.log(als.getStore()); Promise.resolve().then(() => console.log(als.getStore())); }, 0); });