Follow a campaign
Node.js Internals. 12 missions, built to be worked through in order, from file descriptors to cluster.
- 00The primitivesLast opened
- 01ModulesLast opened
- 02EventEmitterLast opened
- 03BuffersLast opened
- 04The event loop and timersLast opened
- 05fs.readFile()Last opened
- 06The thread poolLast opened
- 07StreamsLast opened
- 08net.createServer()Last opened
- 09http.createServer()Last opened
- 10worker_threadsLast opened
- 11clusterLast opened
Look up a side quest
69 standalone quests, each about one mechanism. Name the API, the symptom or the concept you're stuck on.
Altitude, from the hardware up
- Hardware & OS
- Engine
- Runtime
- Framework (runtime)
- Framework (build)
Map shows a system's whole structure. Walkthrough follows one request or piece of data through it. Mission is one step of a campaign.
No quests match that yet
Try another word for the same thing, pick a domain above, or .
OS & hardware
5 entries
Linux
- Hardware & OSLinux OS architectureMap
User space, the kernel, and the two narrow strips between them: syscalls and hardware abstraction.
- Hardware & OSLinux OS architecture: watch data travel the stackWalkthrough
Follow data from a user program through the syscall gate, the kernel and down to the hardware.
- Hardware & OSWhere Node ends and the kernel begins
Node does not implement TCP. Which parts of the network stack belong to Node, the kernel and the hardware.
Also in Node.js › Sockets & networking
Hardware & storage
- Hardware & OSMechanical sympathy in C
Memory is not flat and operations do not cost the same: writing code shaped by the real machine.
- Hardware & OSThe SQLite stack: from db.prepare() to NAND flash
Six layers of indirection between one TypeScript call and the bytes on silicon.
JavaScript & the Web platform
11 entries
Engine & execution
- EngineThe JavaScript engine pipeline
How console.log("Hello") becomes bytes the CPU can execute, at the moment the program runs.
- EngineOne await, traced through the runtime
Closure, iterator, generator, promise, microtask: what a single await is made of.
Binary data
- EngineThe same bytes: binary data from first principles
Storage versus view, endianness, the Buffer pool and the seam where chunks split characters.
- EngineOwn, view, move: how JavaScript holds bytes
Owning bytes is separate from interpreting them. Switch views; the values change, the bytes never do.
- EngineArrayBuffer, TypedArrays and DataView
Every constructor, method and option of the binary primitives that Buffer, Blob and streams build on.
Modules
- Framework (build)ESM vs CommonJS
Why a bundler can prove an ESM graph before running it, but has to execute CommonJS to find out.
Also in Node.js › Modules · Comparisons & decisions
Browser APIs
- Runtimefetch(), end to end
From JavaScript through WebIDL and native C++ into Node.js streams, one block at a time.
Also in Node.js › HTTP
- Runtimefetch() to the wire
The round trip: process model, CORS preflight, the two-stage await and what JavaScript is allowed to read.
- RuntimeEvents: from interrupt to React
One word smeared across five layers, from a hardware interrupt to React's batched handler.
Also in React › Events
- RuntimeInside the browser tab: the URL is your state
push versus replace, URLSearchParams and why the URL should be the source of truth.
- RuntimeTwo stream object models
WHATWG's ReadableStream and Node's stream.Readable are not two spellings of one abstraction.
Also in Node.js › Streams
Node.js
39 entries
Architecture
- RuntimeThe anatomy of Node.jsMap
Seven layers between your JavaScript and the kernel; every fs.readFile hops through all of them.
- RuntimeNode.js architecture: watch a request travel the stackWalkthrough
Core modules, the event loop, the thread pool and the two gates between JavaScript and the kernel.
Modules
- RuntimeModules: resolution, the cache and the cost of cold startMission 01 of 12
Most of your cold start is spent asking the kernel whether files exist.
- Framework (build)ESM vs CommonJS
Why a bundler can prove an ESM graph before running it, but has to execute CommonJS to find out.
Also in JavaScript & the Web platform › Modules · Comparisons & decisions
Event loop & dispatch
- Hardware & OSHow Node.js finds out: a wakeup, or a call
Fifteen notification mechanisms, from a softirq to a promise reaction, asked the same five questions.
- RuntimeWho calls your callback
libuv does not call your JavaScript. Six handoffs, two language boundaries and one copy.
- RuntimeHandle to pointer: the indirection
How a JavaScript object safely stands in for a native pointer, and the [native code] tell.
- RuntimeThe event loop: phases, timers and the two queues that jump themMission 04 of 12
Six phases in a fixed order, a timer heap that shares one syscall with I/O, and two queues outside them.
- RuntimeThe Node.js event loop, deep internals
Phase by phase, from the V8 heap to libuv's epoll, with no hand-waving.
- RuntimeThe thread pool: four subsystems, one queue, four threadsMission 06 of 12
Filesystem, DNS, crypto and zlib all share the pool, which is why one slow call delays the others.
Bytes & Buffers
- RuntimeBytes and the kernel
Node's binary layer from Buffer and the pool to fs syscalls, backpressure and the Node-API bridge.
- RuntimeBuffers: a window onto memory outside the V8 heapMission 03 of 12
The kernel needs an address that does not move, and a garbage collector cannot promise one.
- RuntimeBytes to text
Encodings, decoding and the seam where a character is split across two chunks.
- RuntimeWhose bytes are these?
One byte from the socket to the response, in eleven stops.
- RuntimeWhere are my bytes right now?
Who is holding the data, at every layer, at every instant.
Events
- RuntimeEventEmitter: emit is a for loopMission 02 of 12
A map from names to arrays of functions. emit() is synchronous and queues nothing.
- RuntimeEventEmitter from first principles
Build it yourself: once, mutation mid-emit, the 'error' case and listener leaks.
Streams
- RuntimeStreams: an emitter, a queue of Buffers and one advisory ruleMission 07 of 12
write() returns false when the queue is full, and nothing forces you to listen.
- RuntimeBackpressure: streams from first principles
One signal, traced from the kernel floor through classic streams and Web Streams.
- Runtimestream.Readable and stream.Writable
Two halves of one wire: the same buffer and mark, one signal running each way.
- RuntimeThe producer names an event, not a consumer
Why a Node stream emits into the void and how consumers attach to it.
- RuntimeNode streams, both ends
The same four questions asked of the read side and the write side.
- RuntimeProducer, buffer, consumer
The machinery between a producer that cannot be told to wait and a consumer that runs when it can.
- RuntimeTwo stream object models
WHATWG's ReadableStream and Node's stream.Readable are not two spellings of one abstraction.
Also in JavaScript & the Web platform › Browser APIs
- RuntimeOne socket, two objects
req and res are built the same way: a stream base, an HTTP layer and a framework layer, on one prototype chain.
Also in Node.js › HTTP
File system
- Runtimefs.readFile(), from your JavaScript to the disk and backMission 05 of 12
One line traced through CPU, OS, process, thread, syscall, libuv's worker pool and your callback.
- RuntimeThe fs module
What happens between fs.readFile and your callback, and the whole module surface, measured on Node 22.
Sockets & networking
- Hardware & OSWhere Node ends and the kernel begins
Node does not implement TCP. Which parts of the network stack belong to Node, the kernel and the hardware.
Also in OS & hardware › Linux
- RuntimeThe primitives: descriptors, ports and socketsMission 00 of 12
What a file descriptor indexes, why a port is not an object, and what a socket really is.
- RuntimeWhich of these is the socket?
Five nested layers, the process/kernel boundary, and the second chain that accept() creates.
- Runtimenet.createServer()Mission 08 of 12
Sockets do not use the worker pool. Kernel queues, readiness and epoll instead.
HTTP
- Runtimefetch(), end to end
From JavaScript through WebIDL and native C++ into Node.js streams, one block at a time.
Also in JavaScript & the Web platform › Browser APIs
- Runtimehttp.createServer()Mission 09 of 12
The TCP skeleton plus llhttp: a request across two machines, two kernels and the poll phase.
- RuntimeThe life of one HTTP request
From name resolution to socket reuse, ordered by what is already true at each moment.
- RuntimeOne socket, two objects
req and res are built the same way: a stream base, an HTTP layer and a framework layer, on one prototype chain.
Also in Node.js › Streams
- RuntimeNode.js HTTP from first principles
Express, Next.js and Fastify all reduce to raw TCP bytes parsed by llhttp and handed over as req and res.
Also in HTTP frameworks › Across frameworks
- Framework (runtime)Two bloodlines of req and res
Node, Express and Next compared: who mutates the request, who returns a response, and why.
Also in HTTP frameworks › Across frameworks · Next.js & RSC › Request · Comparisons & decisions
Concurrency
- Runtimeworker_threads: a second Node inside your processMission 10 of 12
Not a thread as you picture it: a whole second runtime, with its own loop and heap.
- Runtimecluster: four processes, one portMission 11 of 12
Two processes cannot both bind port 3000. The answer involves passing a file descriptor.
HTTP frameworks
11 entries
Express
- Framework (runtime)The anatomy of ExpressMap
A function handed to Node's server, a stack of Layer objects, and augmented req/res prototypes.
- Framework (runtime)Express architecture: watch a request travel the whole stackWalkthrough
Express's Layer stack and next(), on top of the whole Node.js runtime.
- Framework (runtime)Express: the anatomy of the library
The source, module by module: application, request, response and the router.
- Framework (runtime)Where req and res get their powers
Express glues keys onto Node's own objects; Next.js subclasses the Web's Request instead.
- Framework (runtime)When does req.body exist?
Your file runs once and a request walks it every time. That one fact explains middleware order.
- Framework (runtime)Router, Layer, Route
How Express 5 routing works and what each composition idiom actually builds.
- Framework (runtime)What happens under app.get
Router, Route, Layer and middleware dispatch in Express 5, driven by a real routing engine.
Fastify
- Framework (runtime)Fastify: compiled before the first request
Routes, schemas and hooks compiled at startup, so the request path does less work.
Across frameworks
- RuntimeNode.js HTTP from first principles
Express, Next.js and Fastify all reduce to raw TCP bytes parsed by llhttp and handed over as req and res.
Also in Node.js › HTTP
- Framework (runtime)Two bloodlines of req and res
Node, Express and Next compared: who mutates the request, who returns a response, and why.
Also in Node.js › HTTP · Next.js & RSC › Request · Comparisons & decisions
- Framework (runtime)Express decorates Node, Next extends the Web
Two ways to give a request object more power, and the lifecycle each one produces.
Also in Next.js & RSC › Request · Comparisons & decisions
React
2 entries
Foundations
- Framework (runtime)React from first principles
A plain object and a loop that turns it into pixels, built from scratch.
Events
- RuntimeEvents: from interrupt to React
One word smeared across five layers, from a hardware interrupt to React's batched handler.
Also in JavaScript & the Web platform › Browser APIs
Next.js & RSC
22 entries
Request
- Framework (runtime)Two bloodlines of req and res
Node, Express and Next compared: who mutates the request, who returns a response, and why.
Also in Node.js › HTTP · HTTP frameworks › Across frameworks · Comparisons & decisions
- Framework (runtime)Express decorates Node, Next extends the Web
Two ways to give a request object more power, and the lifecycle each one produces.
Also in HTTP frameworks › Across frameworks · Comparisons & decisions
- Framework (runtime)The anatomy of a Next.js request
One program across a build pipeline, a server runtime and the browser, from socket to hydrated UI.
- Framework (runtime)The App Router, end to end
From a packet on the wire through routing and the two-pass RSC/SSR render, into the client router.
- Framework (runtime)Two renderers, one request
An App Router page is rendered twice, into two wire formats, over one streamed response.
- Framework (runtime)App Router vs Pages Router
Two complete routing systems in one framework, compared layer by layer.
Also in Comparisons & decisions
- Framework (runtime)Next.js 16 vs TanStack Start
Two answers to the same question about where rendering and data loading should live.
Also in Comparisons & decisions
RSC & Flight
- Framework (runtime)RSC: the data flowMap
The ordered pipeline from request to interactive, crossing the network once.
- Framework (runtime)RSC: the full data flow, explorableWalkthrough
Every step from browser request to interactive app: payload, hydration and boundaries.
- Framework (runtime)RSC: between request and interactive
What the server renders, what it serializes and what the browser does with the stream.
- Framework (runtime)Crossing the network boundary
One program across two computers: bundling decides where code runs and what crosses the wire.
- Framework (runtime)The Flight payload from first principles
self.__next_f.push, tagged tuples and the bootstrap line: one source, two outputs.
- Framework (runtime)RootLayout to HTML and Flight
How your layout.js becomes two coordinated outputs in the initial page response.
- Framework (runtime)The exact order: RSC, Flight, HTML, paint, hydrate
One render, two outputs, braided into one response: what happens first and why.
- Framework (runtime)The renderer parks it: async Server Components
How an async component suspends on await, becomes a Flight task and resumes.
- Framework (runtime)The client-reference bridge
From <Counter/> to proxy, manifest, Flight metadata, __webpack_require__ and hydration.
- Framework (build)The 'use client' doorway
Past the metaphor: the wire format, manifest entries and encrypted closures in Next.js 16.
Data plumbing
- Framework (runtime)Three doorways into one server
Route handlers, Server Actions and Server Components: contract, policy and what crosses the wire.
- Framework (runtime)Next.js server primitives and the DAL
One mutation's round trip through Server Actions, a data access layer and revalidation.
Build
- Framework (build)The anatomy of a Next.js 16 build
Thirteen phases between your app/ directory and the .next folder you deploy.
- Framework (build)What happens when you run next build
Config, route discovery, Rust-based compilation, module tracing and pruning, in order.
- Framework (build)The Next.js 16 compiler pipeline
What the build reads, what it transforms and the runtime maps it leaves behind.
Comparisons & decisions
6 entries
- RuntimeThe runtime royal rumble
Ten languages, thirty runtimes: a language is a spec, a runtime is what actually runs.
- Framework (runtime)Two bloodlines of req and res
Node, Express and Next compared: who mutates the request, who returns a response, and why.
Also in Node.js › HTTP · HTTP frameworks › Across frameworks · Next.js & RSC › Request
- Framework (runtime)Express decorates Node, Next extends the Web
Two ways to give a request object more power, and the lifecycle each one produces.
Also in HTTP frameworks › Across frameworks · Next.js & RSC › Request
- Framework (runtime)App Router vs Pages Router
Two complete routing systems in one framework, compared layer by layer.
Also in Next.js & RSC › Request
- Framework (runtime)Next.js 16 vs TanStack Start
Two answers to the same question about where rendering and data loading should live.
Also in Next.js & RSC › Request
- Framework (build)ESM vs CommonJS
Why a bundler can prove an ESM graph before running it, but has to execute CommonJS to find out.
Also in JavaScript & the Web platform › Modules · Node.js › Modules