Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumNodeJSasync_hooks for contextSingle-choice MCQ

You use AsyncLocalStorage to carry a request id. Inside a setTimeout scheduled within the als.run() callback, what does als.getStore() return?

const { AsyncLocalStorage } = require('async_hooks'); const als = new AsyncLocalStorage(); als.run({ id: 'A' }, () => { setTimeout(() => { console.log(als.getStore()?.id); }, 10); }); console.log(als.getStore());