> cs·fundamentals
interview 0% an interactive refresher
04 [J][I][A] Stage 2

Node.js Internals

The one language-specific module: the event loop, async evolution, streams, modules, CPU-bound concurrency, and V8 memory. Targets Node 24 LTS.

chapters
6
objectives
21
core
12
est. time
2h 18m
  1. 01
    4.1 The event loop & async model ★ core

    Single-threaded JS + libuv thread pool, the event-loop phases in order, microtasks vs macrotasks, and the nextTick/setImmediate/setTimeout ordering rules.

    6 objectives · 2 readings · 30m
  2. 02
    4.2 Async evolution & error handling ★ core

    Callbacks → Promises → async/await, and the error-handling traps: unhandled rejections and floating promises.

    2 objectives · 20m
  3. 03
    4.3 Streams & buffers

    The four stream types, backpressure (why pipe/pipeline handle it), buffers for binary data, and the must-handle 'error' event.

    4 objectives · 1 readings · 24m
  4. 04
    4.4 Modules & packages ★ core

    CommonJS vs ES Modules (and the exports vs module.exports gotcha), plus npm/package.json: deps vs devDeps, semver, lockfiles.

    2 objectives · 1 readings · 20m
  5. 05
    4.5 Globals, events & CPU concurrency

    process/global/Buffer, the EventEmitter pattern, and picking worker threads vs child processes vs cluster for CPU-bound work.

    3 objectives · 1 readings · 22m
  6. 06
    4.6 V8, memory & frameworks

    V8 + GC basics and how memory leaks happen, Express/Fastify/NestJS at a concept level, debugging with --inspect, and the common Node gotchas.

    4 objectives · 22m

Section assessment

Harder, multi-concept questions drawn from across the module. Aim for 75%.

section assessment12 questions · pass ≥ 75%
  1. 01hard

    INSIDE an fs.readFile callback, which fires first?

  2. 02hard

    What is logged?

    async function f(){ throw new Error('boom'); }
    try { f(); } catch (e) { console.log('caught'); }
    console.log('after');
  3. 03hard

    CPU-heavy image processing that must not block the HTTP server, sharing memory with the main process, calls for:

  4. 04medium

    What does this print?

    console.log('A');
    setTimeout(() => console.log('B'), 0);
    Promise.resolve().then(() => console.log('C'));
    process.nextTick(() => console.log('D'));
    console.log('E');
  5. 05medium

    After each operation, Node drains which queue FIRST?

  6. 06medium

    What actually runs Node's async I/O (fs, DNS, crypto) off the main thread?

  7. 07medium

    A “floating promise” is dangerous because:

  8. 08medium

    Backpressure is signalled when:

  9. 09medium

    In CommonJS, reassigning `exports = {...}` (instead of `module.exports`) is a gotcha because:

  10. 10medium

    cluster is mainly used to:

  11. 11medium

    Common Node memory-leak sources:

  12. 12easy

    A long synchronous for-loop in a request handler blocks all other requests.