Complete Index
Browse all chapters and topics in NodeBook
Node.js Architecture
Click to view all topics in this chapter
What Node.js Is
What Node.js is, how V8, libuv, native bindings, and core APIs fit together, and how JavaScript reaches files, sockets, timers, and the OS.
V8 in Node.js
How the V8 JavaScript engine architecture in Node.js runs Ignition bytecode, tiered JIT compilation, shapes, inline caches, and deoptimization.
Node.js Event Loop
Node.js event loop explained through libuv phases, timers, poll, check, close callbacks, process.nextTick, promise microtasks, and setImmediate order.
Node.js Process Lifecycle
A normal Node.js process starts by initializing V8 and libuv, loading the entry module, then staying alive while referenced handles and requests remain active.
Buffers
Click to view all topics in this chapter
What Is a Buffer?
What a Buffer is in Node.js: a fixed-size mutable byte sequence for files, sockets, hashes, images, compressed payloads, and undecoded I/O.
Buffer Allocation
How Buffer.alloc, Buffer.allocUnsafe, Buffer.from, slab pooling, and large Buffer allocation affect memory safety and performance in Node.js.
Buffer Operations
How Buffer views, copies, TypedArray interop, worker transfer, and zero-copy parsing affect byte ownership in Node.js.
Buffer Fragmentation, Retained Views, and External Memory
How Buffer allocation can fragment external memory, pin large backing stores, interact with V8 accounting, and create performance problems in Node.js.
Streams
Click to view all topics in this chapter
Stream Foundations
How Node.js moves chunked data through stream queues, consumption modes, and backpressure without treating every input as one value.
Readable Streams
How Node.js Readable streams buffer data, switch between flowing and paused mode, apply highWaterMark, and signal backpressure.
Writable Streams
How Writable streams accept chunks, buffer writes, use highWaterMark, return false from write, and emit drain for backpressure.
Transform Streams
How Transform and Duplex streams work in Node.js, how _transform and _flush emit output, and how backpressure crosses both sides.
Stream Pipeline
How pipe, stream.pipeline, finished, async pipeline stages, AbortSignal, side outputs, and partial-output cleanup work in current Node.js stream pipelines.
Zero-Copy Streams
How Buffer ownership, fs.copyFile, writev, _writev, cork, and copy-path measurement shape hot Node.js stream paths.
File System
Click to view all topics in this chapter
File Descriptors & Handles
How file descriptors and FileHandle objects map to OS file state, open flags, close behavior, libuv work, and EMFILE failures.
File I/O
How Node.js reads and writes files through whole-file helpers, streams, low-level read/write calls, append mode, and durable flushes.
fs.promises & FileHandle
How fs.promises and FileHandle work in Node.js, including async file operations, descriptor ownership, stream lifecycles, cleanup, and controlled concurrency.
fs.watch & Atomic Writes
How fs.watch, fs.watchFile, OS watcher backends, and atomic replacement patterns interact in real file workflows.
Permissions & Metadata
How Node.js exposes file permissions, ownership, stat metadata, symlinks, inodes, sparse files, special paths, and filesystem edge cases.
Process & OS
Click to view all topics in this chapter
process Object
How the Node.js process object exposes env, argv, pid, cwd, exit state, memory usage, versions, IPC, and native process bindings.
Signals & Exit Codes
How Node.js handles SIGTERM, SIGINT, exit codes, beforeExit, exit, uncaught exceptions, and graceful shutdown across process scopes.
os Module
How the Node.js os module reports CPU counts, available parallelism, memory, load average, network interfaces, paths, users, and platform data.
Standard I/O
How Node.js standard input, output, and error streams map to file descriptors, TTYs, pipes, console output, and backpressure.
The Module System
Click to view all topics in this chapter
CJS require() Internals
How Node.js require works internally through resolution, Module._load, source wrapping, compilation, module.exports, and require.cache.
Module Resolution
How Node.js resolves module specifiers through built-ins, relative paths, node_modules lookup, package.json main, exports, imports, and symlinks.
ES Modules
How ES Modules work in Node.js through static import/export syntax, module format detection, parse-link-evaluate phases, and live bindings.
CommonJS/ESM Interop
How CommonJS and ES Modules interoperate in Node.js through CJS namespaces, require(esm), conditional exports, and dual package design.
import.meta & ESM Caching
How import.meta, import.meta.url, import.meta.dirname, the ESM module cache, circular dependencies, and module state work in Node.js.
Async Patterns & Control Flow
Click to view all topics in this chapter
Error-First Callbacks
How Node.js error-first callbacks work, why the first argument carries errors, and how callback dispatch connects native async work back to JavaScript.
Promise Microtasks
How Node.js orders Promise jobs, process.nextTick callbacks, queueMicrotask work, timers, and I/O across CommonJS, ES modules, and active microtask drains.
Async/Await
How async functions and await work in Node.js through promise wrapping, suspension, resumption, microtasks, errors, and V8 state machines.
EventEmitter Internals
How EventEmitter stores listeners, dispatches emit synchronously, handles error events, preserves listener order, and reports possible leaks.
Async Iterators
How async iterators work in Node.js through Symbol.asyncIterator, for await...of, async generators, stream consumption, and backpressure.
Promise Combinators
How Promise.all, allSettled, race, and any behave in Node.js, including short-circuiting, failure propagation, cancellation gaps, and concurrency limits.
Runtime Platform APIs & Tooling
Click to view all topics in this chapter
CLI Flags
How Node.js consumes startup flags, NODE_OPTIONS, preloads, V8 options, source maps, conditions, warnings, diagnostics, memory flags, node --run, and experimental config files.
.env Files
How Node.js loads .env files with --env-file, parses DotEnv syntax, resolves precedence, handles NODE_OPTIONS, uses process.loadEnvFile() and util.parseEnv(), and turns raw strings into validated config.
Web Platform APIs
How Node.js exposes web-compatible globals including fetch, Request, Response, Web Streams, Blob, File, FormData, URL, and structuredClone.
TypeScript & Compile Cache
How Node.js v24.15 runs TypeScript through type stripping, handles .ts module formats, rejects unsupported syntax, and stores compile cache data.
REPL, Inspector, Watch & SEA
How Node.js REPL, inspector sessions, watch mode, and single executable applications evaluate code, expose debugging state, restart, and package apps.
Network Fundamentals with Node.js
Click to view all topics in this chapter
TCP/IP Networking
How Node.js networking depends on OS sockets, TCP/IP state, addresses, ports, routing, link-layer resolution, MTU, and libuv handles.
DNS Resolution
How Node.js resolves hostnames through dns.lookup, dns.resolve, OS resolver behavior, c-ares, recursive DNS, TTLs, caching, and address ordering.
TCP Flow & Failure
How Node.js TCP connections move through handshake, flow control, ordered delivery, FIN, RST, ECONNRESET, EPIPE, ETIMEDOUT, and shutdown.
Sockets and net
How Node.js net.Server and net.Socket wrap OS socket state, libuv TCP handles, connection events, writes, shutdown, timeouts, and IPC endpoints.
UDP and dgram
How Node.js UDP sockets work through dgram, datagram framing, send and message events, bind state, broadcast, multicast, connected UDP, and errors.
Socket Options & Backlog
How Node.js exposes socket options including keepAlive, noDelay, backlog, SO_REUSEADDR, send and receive buffers, IPv4/IPv6 binding, and dual stack behavior.
Request Path
Trace a Node.js connection from hostname lookup through address selection, routing, TCP connect, accept queues, libuv readiness, and JavaScript callbacks.