Runtime
Node.js event loop: scheduling boundaries
The current synchronous work runs before an immediate callback scheduled by that work. The event loop coordinates later callbacks, while microtasks have separate scheduling boundaries. This fixture proves only a controlled order, not a universal order between timers and immediates or all CJS/ESM contexts. Tested on Node.js 22.16.0. Example output (one line per entry): ["start > end > later"].
Formal Syntax & Structure
nodejs syntaxnodejs
Concept: synchronous stack → queued callbacksReturn Value
Concept
No API return value; observed callback order.
Working Example
Example Snippetnodejs
import { setImmediate as turn } from 'node:timers/promises';const trace = ['start'];setImmediate(() => trace.push('later'));trace.push('end');await turn();console.log(trace.join(' > '));