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

Given this code, what does the `before` hook see, and why is the captured async context for the inner `setTimeout` what it is?

const ah = require('async_hooks'); let outerId; ah.createHook({ init(id, type, triggerId) { if (type === 'Timeout') console.log(`init ${id} triggeredBy ${triggerId}`); } }).enable(); setTimeout(function outer() { outerId = ah.executionAsyncId(); setTimeout(function inner() {}, 0); }, 0);