Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ledger — Node.js (nodejs.md)

Chapter: nodejs.md (Section G). Scope: Node.js v24.21.0 ‘Krypton’ LTS (retrieved 2026-10-13 via nodejs.org/dist/index.json; embedded V8 13.6.233.17, libuv 1.52.1), Linux reference platform, POSIX deltas labeled, Windows brief.

Sources (all retrieved 2026-10-13): nodejs.org/docs/latest-v24.x/api/ — process.html, child_process.html, worker_threads.html, cluster.html, events.html, os.html, util.html, cli.html, modules.html, esm.html; nodejs.org/learn/asynchronous-work/event-loop-timers-and-nexttick; docs.libuv.org/en/v1.x/threadpool.html. All sources reachable; no source-limited rows.

Status definitions: not-started (no work), researched (verified, not yet written into the chapter), documented (chapter explanation + examples/citations complete), source-limited (claim recorded but primary source unreachable/partial).

Rollup: Inventoried: 80 / Documented: 80 / Remaining: 0 / Source-limited: 0

IDLanguage/API or behaviorCanonical signatureDocumentation pathAuthoritative referenceVersion/platform scopeStatus
PL-ND-001Functions, arrow this-binding, closures(args) => { … } (lexical this); function (…) { … } (dynamic this)./nodejs.md §1.1ECMAScript engine behavior as exposed by Node (V8 13.6); ch. §1.1 example[JS language]; all Node v24documented
PL-ND-002Classes, prototypes, field init orderclass C extends B { field = …; constructor() {} }./nodejs.md §1.2ch. §1.2[JS language]; all Node v24documented
PL-ND-003Promise states, chaining, rejection propagationnew Promise(executor); p.then(onF, onR).catch(onR).finally(f)./nodejs.md §1.3ch. §1.3 example (A/B output)[JS language]; all Node v24documented
PL-ND-004async/await = promise chains; await resumption is a microtaskasync function f() { await p; }./nodejs.md §1.4ch. §1.4 example (microtask-before-timer)[JS language]; all Node v24documented
PL-ND-005CommonJS require: synchronous load/evaluaterequire(modulePath); module.exports./nodejs.md §1.6modules.html, nodejs.org/docs/latest-v24.x/api/modules.html[Node documented]; CJS .cjs/.js non-type:moduledocumented
PL-ND-006ESM import: graph parse→instantiate→evaluate; top-level await ESM-onlyimport … from 'mod'; top-level await./nodejs.md §1.6esm.html, nodejs.org/docs/latest-v24.x/api/esm.html[Node documented]; ESM .mjs/type:moduledocumented
PL-ND-007require(esm) non-experimental; only synchronous ESM; ERR_REQUIRE_ASYNC_MODULErequire(esmModule)./nodejs.md §1.6modules.html#loading-ecmascript-modules-using-require (“no longer experimental” v24.15.0; unflagged v23.0.0/v22.12.0/v20.19.0)Node ≥ v24.15 (v22.12/v20.19 unflagged)documented
PL-ND-008Error subclasses; throw vs rejection; Node error familiesthrow err; Error, TypeError, SystemError (err.code/syscall/errno), AbortError./nodejs.md §1.5ch. §1.5; child_process.html (‘error’ ENOENT shape §5.9)[JS language] + [Node documented]documented
PL-ND-009Event loop phases: timers → pending callbacks → idle,prepare → poll → check → close—./nodejs.md §1.7nodejs.org/learn/asynchronous-work/event-loop-timers-and-nexttick (phases table; timers-after-poll since libuv 1.45.0/Node 20)[Node documented]/[libuv] ≥ 1.45.0 note; v24documented
PL-ND-010Loop drain = clean shutdown check between iterations—./nodejs.md §1.7, §3.1event-loop guide: “shuts down cleanly if there are not any”[Node documented]; v24documented
PL-ND-011Microtask vs macrotask; nextTick vs queueMicrotask order reverses CJS↔ESMprocess.nextTick(cb[, ...args]); queueMicrotask(cb)./nodejs.md §1.7process.html#when-to-use-queuemicrotask-vs-processnexttick (CJS: nextTick first; ESM: microtasks first)[Node documented]; v24documented
PL-ND-012Uncaught exception default: stderr stack + exit 1 (overrides exitCode); unhandled rejection default throw (crash) since v15.0.0—./nodejs.md §1.8process.html#event-uncaughtexception; cli.html#–unhandled-rejectionsmode (flag added v12.0.0/v10.17.0; warning-before-v15)Node v24; default in force v15→v24documented
PL-ND-013process.exitprocess.exit([code])./nodejs.md §3.3process.html#processexit (added v0.1.13; v20.0.0 integer/integer-string only)Node v24documented
PL-ND-014process.exitCode propertyprocess.exitCode → <integer> | <string> | <null> | <undefined> (default undefined)./nodejs.md §3.4process.html#processexitcode (added v0.11.8)Node v24documented
PL-ND-015process.abort (immediate exit + core file; not in Workers)process.abort()./nodejs.md §3.5process.html#processabort (added v0.7.0)Node v24; main thread onlydocumented
PL-ND-016process.kill (signal sender; throws on missing pid; signal 0 probe; Windows group-pid error)process.kill(pid[, signal])./nodejs.md §4.3process.html#processkillpid-signal (added v0.0.6; default ‘SIGTERM’)Node v24; negative-pid POSIX onlydocumented
PL-ND-017process.pidprocess.pid → <integer>./nodejs.md §2.1process.html#processpid (added v0.1.15)Node v24documented
PL-ND-018process.nextTick Legacy status; infinite nextTick starves loopprocess.nextTick(callback[, ...args])./nodejs.md §1.7process.html#processnexttickcallback-args (Stability: 3 - Legacy since v22.7.0/v20.18.0; added v0.1.26)Node v24documented
PL-ND-019process.env copy semantics (no external effect; workers get copy v11.14.0)process.env → <Object>./nodejs.md §2.1process.html#processenv (added v0.1.27; “such modifications will not be reflected outside the Node.js process”)Node v24documented
PL-ND-020process.chdir throws on failure; process.cwdprocess.chdir(directory); process.cwd() → <string>./nodejs.md §2.1, §4.5process.html#processchdirdirectory (added v0.1.17)Node v24; POSIX cwddocumented
PL-ND-021process.umask get/set; children inherit maskprocess.umask([mask])./nodejs.md §2.1, §4.5process.html#processumaskmask (added v0.1.19)Node v24; POSIX umask(2)documented
PL-ND-022process.setuid/setgid (name strings block resolving)process.setuid(id); process.setgid(id)./nodejs.md §2.1, §4.5process.html#processsetuidid / #processsetgidid (setgid added v0.1.31)Node v24; privileged opsdocumented
PL-ND-023process.initgroups/groups (reads /etc/group; root or CAP_SETGID)process.initgroups(user, extraGroup)./nodejs.md §2.1, §4.5process.html#processinitgroupsuser-extragroup (added v0.9.4)Node v24; Linux/POSIX privilegeddocumented
PL-ND-024os.availableParallelism (not os.cpus().length)os.availableParallelism() → <integer>./nodejs.md §2.2os.html#osavailableparallelism (added v19.4.0/v18.14.0)Node ≥ 18.14documented
PL-ND-025util.convertProcessSignalToExitCode (signal name → 128+N; throws invalid)util.convertProcessSignalToExitCode(signal) → <number>./nodejs.md §2.2, §5.12util.html#utilconvertprocesssignaltoexitcodesignal (added v24.14.0)Node ≥ v24.14documented
PL-ND-026events.setMaxListeners / defaultMaxListeners (10 default)events.setMaxListeners(n[, ...eventTargets]); events.defaultMaxListeners./nodejs.md §2.2events.html#eventssetmaxlistenersn-eventtargets (v15.4.0); #eventsdefaultmaxlisteners (v0.11.2)Node v24documented
PL-ND-027Normal exit code 0 when loop drains—./nodejs.md §3.1process.html#exit-codes (“normally exit with a 0 status code when no more async operations are pending”)Node v24documented
PL-ND-028Exit code 1 = Uncaught Fatal Exception—./nodejs.md §3.2process.html#exit-codesNode v24documented
PL-ND-029Internal exit codes 3/4/5/6/7/10 (bootstrap/V8/internal-handler)—./nodejs.md §3.2process.html#exit-codes (verbatim table)Node v24documented
PL-ND-030Exit codes 9 (Invalid Argument), 12 (Invalid Debug Argument), 13 (Unsettled Top-Level Await), 14 (Snapshot Failure)—./nodejs.md §3.2process.html#exit-codes (13 wording updated from v22 “Unfinished”)Node v24documented
PL-ND-031Signal exits: status 128 + signal number (>128)—./nodejs.md §3.2process.html#exit-codes (“standard POSIX practice”; SIGABRT=6 → 134)Node v24; Linux/POSIX shellsdocumented
PL-ND-032'exit' event: sync-only listeners; async work abandoned; no prevention possibleprocess.on('exit', (code) => {})./nodejs.md §3.8process.html#event-exit (added v0.1.7; “Listener functions must only perform synchronous operations”)Node v24documented
PL-ND-033'beforeExit': loop-empty trigger; async work keeps alive; not on explicit exit/uncaught; gets exitCode argprocess.on('beforeExit', (code) => {})./nodejs.md §3.8process.html#event-beforeexit (added v0.11.12; “not emitted for conditions causing explicit termination”)Node v24documented
PL-ND-034'uncaughtException' handler overrides default; handler throwing → nonzero exit; origin argumentprocess.on('uncaughtException', (err, origin) => {})./nodejs.md §3.6process.html#event-uncaughtexception (added v0.1.18; origin v12.0.0/v10.17.0; crash-warning section quoted)Node v24documented
PL-ND-035'uncaughtExceptionMonitor' observes without changing behaviorprocess.on('uncaughtExceptionMonitor', (err, origin) => {})./nodejs.md §3.6process.html#event-uncaughtexceptionmonitor (added v13.7.0/v12.17.0)Node ≥ 12.17documented
PL-ND-036--unhandled-rejections modes: throw (default)/strict/warn/warn-with-error-code/none; ESM static-loading rejection always uncaughtnode --unhandled-rejections=mode./nodejs.md §3.7cli.html#–unhandled-rejectionsmode (added v12.0.0/v10.17.0; throw default since v15.0.0)Node v24documented
PL-ND-037'unhandledRejection' event; unhandled event → uncaught exceptionprocess.on('unhandledRejection', (reason, promise) => {})./nodejs.md §3.7process.html#event-unhandledrejection (added v1.4.1; warn v6.6.0; deprecation v7.0.0)Node v24documented
PL-ND-038Worker/cluster termination vs main process (worker ‘exit’ exitCode=1 when terminated; cluster = child_process.fork processes)worker.on('exit', (exitCode) => {})./nodejs.md §3.9, §6.3worker_threads.html#event-exit; cluster.html (“worker processes are spawned using the child_process.fork() method”)Node v24documented
PL-ND-039Signal events: name passed to handler; unavailable in Worker threadsprocess.on('SIGINT' | 'SIGTERM' | …, (signal) => {})./nodejs.md §4.1process.html#signal-events (refers to signal(7))Node v24; main threaddocumented
PL-ND-040SIGTERM/SIGINT default handlers removed by listener (Ctrl+C no longer kills); cleanup + re-raise—./nodejs.md §4.1process.html#signal-events (default-removal quote); child_process.html#event-exit (re-raise note)Node v24; non-Windows defaultsdocumented
PL-ND-041SIGKILL/SIGSTOP cannot have listeners; SIGSEGV/SIGBUS/SIGFPE/SIGILL unsafe for JS—./nodejs.md §4.2process.html#signal-events (verbatim per-signal list)Node v24; all platformsdocumented
PL-ND-042Platform catalog: SIGBREAK (Win Ctrl+Break), SIGHUP (Win ~10 s), SIGTERM not supported on Windows, SIGPIPE ignored, SIGUSR1 debugger-reserved, SIGWINCH—./nodejs.md §4.2, §4.7process.html#signal-events + Windows-emulation paragraphNode v24; Windows deltas labeleddocumented
PL-ND-043Signal 0 existence probe; Windows emulation of SIGINT/SIGTERM/SIGKILLprocess.kill(pid, 0)./nodejs.md §4.2, §4.3process.html#signal-events (“0 can be sent to test for the existence of a process”)Node v24documented
PL-ND-044Signal listener keeps the loop alive; no public unref — removeListener restores defaultprocess.on(…) / process.removeListener(…)./nodejs.md §4.4ch. §4.4 (derived from process.html#signal-events example using stdin.resume(); docs example keeps process alive)Node v24documented
PL-ND-045Credentials/umask/chdir are synchronous privileged syscalls on the loop threadprocess.setuid/setgid/initgroups/umask/chdir./nodejs.md §4.5process.html#processinitgroupsuser-extragroup (“privileged operation…root or CAP_SETGID”); setuid/setgid “blocks while resolving”Node v24; Linux/POSIXdocumented
PL-ND-046spawn signature and streaming model (no maxBuffer option on async spawn)child_process.spawn(command[, args][, options]) → <ChildProcess>./nodejs.md §5.1, §5.2child_process.html#child_processspawncommand-args-options (added v0.1.90)Node v24documented
PL-ND-047spawn options cwd/env/argv0 (ENOENT on missing cwd or command; undefined env values ignored)options.cwd/options.env/options.argv0./nodejs.md §5.2child_process.html#child_processspawncommand-args-options (argv0 v6.4.0)Node v24documented
PL-ND-048options.stdio: ‘pipe’/‘overlapped’/‘ignore’/‘inherit’ shorthands; array per-fd; extra fds; ‘ipc’ at most one; not /dev/fd Noptions.stdio <Array> | <string>./nodejs.md §5.3child_process.html#optionsstdio (added v0.7.10; ‘overlapped’ v15.6.0/v14.18.0)Node v24documented
PL-ND-049options.detached: new process group+session on POSIX (setsid(2)); unref pattern; stdio:‘ignore’ for daemonizationoptions.detached <boolean> + subprocess.unref()./nodejs.md §5.4child_process.html#optionsdetached (added v0.7.10; docs example quoted)Node v24; Windows makes own consoledocumented
PL-ND-050spawn/fork/exec uid/gid options (setuid(2)/setgid(2) pre-exec)options.uid <number>; options.gid <number>./nodejs.md §5.2child_process.html#child_processspawncommand-args-optionsNode v24; Linux/POSIXdocumented
PL-ND-051options.serialization ‘json’ (default) / ‘advanced’options.serialization <string>./nodejs.md §5.2, §5.6child_process.html (added v13.2.0/v12.16.0; Advanced serialization for child_process)Node ≥ 12.16/13.2documented
PL-ND-052options.shell (false default; ‘/bin/sh’ or ComSpec); DEP0190 args+shell deprecation; windowsVerbatimArguments/windowsHideoptions.shell <boolean> | <string>./nodejs.md §5.2, §5.5child_process.html#child_processspawncommand-args-options (shell v5.7.0; DEP0190 v23.11.0/v22.15.0; windowsHide v8.8.0)Node v24documented
PL-ND-053options.timeout auto-kill with killSignal (single signal, no escalation) + options.signal AbortSignaloptions.timeout <number>; options.signal <AbortSignal>; options.killSignal./nodejs.md §5.2, §5.10child_process.html (timeout v15.13.0/v14.18.0; signal v15.5.0/v14.17.0; abort killSignal v15.11.0/v14.18.0)Node ≥ 14.17/15.13documented
PL-ND-054spawnSync blocks loop; returns {pid,output,stdout,stderr,status,signal,error}; encoding ‘buffer’; maxBuffer 1 MiB terminate+truncate; input overrides stdio[0]child_process.spawnSync(command[, args][, options]) → <Object>./nodejs.md §5.7child_process.html#child_processspawnsynccommand-args-options (added v0.11.12; “will not return until the child process has fully closed”)Node v24documented
PL-ND-055execFileSync/execSync block event loop (execSync still shell-based)child_process.execFileSync(file[, args][, options]); child_process.execSync(command[, options])./nodejs.md §5.7child_process.html#child_processexecfilesync / #child_processexecsync (both added v0.11.12; “block the Node.js event loop”)Node v24documented
PL-ND-056exec spawns shell, buffers output; “Never pass unsanitized user input”child_process.exec(command[, options][, callback])./nodejs.md §5.5child_process.html#child_processexeccommand-options-callback (added v0.1.90; AbortSignal v15.4.0; “does not replace the existing process”)Node v24documented
PL-ND-057exec buffering: maxBuffer default 1024*1024, exceeded → child terminated + truncated (Unicode caveat); error.code=exit code, error.signaloptions.maxBuffer <number>; callback(error, stdout, stderr)./nodejs.md §5.5child_process.html#child_processexeccommand-options-callback (maxBuffer and Unicode caveat)Node v24documented
PL-ND-058execFile no shell by default; Windows .bat/.cmd not launchable via execFilechild_process.execFile(file[, args][, options][, callback])./nodejs.md §5.6child_process.html#child_processexecfilefile-args-options-callback (added v0.1.91; Spawning .bat and .cmd on Windows section)Node v24; Windows deltasdocumented
PL-ND-059fork IPC channel; execPath/execArgv (default process.execArgv)/silent options; child process.send/‘message’/‘disconnect’child_process.fork(modulePath[, args][, options])./nodejs.md §5.6child_process.html#child_processforkmodulepath-args-options (added v0.5.0; silent semantics verbatim)Node v24documented
PL-ND-060subprocess.pid undefined on spawn failure + ‘error’ emittedsubprocess.pid → <integer> | <undefined>./nodejs.md §5.8child_process.html#subprocesspid (added v0.1.90)Node v24documented
PL-ND-061subprocess.kill([signal]) returns boolean (kill(2) success); default SIGTERMsubprocess.kill([signal]) → <boolean>./nodejs.md §5.8, §5.10child_process.html#subprocesskillsignal (added v0.1.90)Node v24documented
PL-ND-062subprocess.killed = signal sent, NOT terminated (verbatim)subprocess.killed → <boolean>./nodejs.md §5.8child_process.html#subprocesskilled (added v0.5.10; “does not indicate that the child process has been terminated”)Node v24documented
PL-ND-063subprocess.ref()/unref() (loop reference count; IPC-channel exception)subprocess.unref(); subprocess.ref()./nodejs.md §5.8child_process.html#subprocessunref / #subprocessref (added v0.7.10)Node v24documented
PL-ND-064subprocess.connected / disconnect() (child may call process.disconnect too)subprocess.disconnect(); subprocess.connected → <boolean>./nodejs.md §5.6, §5.8child_process.html#subprocessdisconnect / #subprocessconnected (added v0.7.2)Node v24documented
PL-ND-065subprocess.send (boolean flow control since v5.0.0; callback v4.0.0; keepOpen v5.8.0) + ‘message’/‘disconnect’ eventssubprocess.send(message[, sendHandle[, options]][, callback])./nodejs.md §5.6, §5.8child_process.html#subprocesssendmessage-sendhandle-options-callback (added v0.5.9)Node v24documented
PL-ND-066subprocess.stdio sparse array; stdin/stdout/stderr aliases; null for non-pipe fdssubprocess.stdio → <Array> (v0.7.10)./nodejs.md §5.8child_process.html#subprocessstdioNode v24documented
PL-ND-067child 'exit' event: code/signal exactly one non-null; stdio streams may still be open; waitpid(2) reaping linkchild.on('exit', (code, signal) => {})./nodejs.md §5.9, §5.11child_process.html#event-exit (added v0.1.90)Node v24documented
PL-ND-068child 'close' event: after stdio streams closed; always after ‘exit’ or spawn-failure ‘error’child.on('close', (code, signal) => {})./nodejs.md §5.9child_process.html#event-close (added v0.7.7)Node v24documented
PL-ND-069child 'error' events: 4 documented causes; ‘exit’ may or may not fire after error; guard double invocation; ENOENT = spawn failurechild.on('error', (err) => {})./nodejs.md §5.9child_process.html#event-errorNode v24documented
PL-ND-070subprocess.exitCode/signalCode live status; signal→POSIX code via util API; ‘spawn’ event (v15.1.0/v14.17.0)subprocess.exitCode <integer>; subprocess.signalCode <string>./nodejs.md §5.8, §5.12child_process.html#subprocessexitcode / #subprocesssignalcode / #event-spawnNode v24 (converter ≥ v24.14)documented
PL-ND-071Zombies reaped by libuv waitpid after ‘exit’; orphans on parent death; no PDEATHSIG option—./nodejs.md §5.11child_process.html#event-exit (“See waitpid(2)”); ch. §5.11 (POSIX reparenting)Node v24; Linux/POSIXdocumented
PL-ND-072Single-threaded JS + global libuv threadpool (default 4, UV_THREADPOOL_SIZE max 1024; fs/crypto/dns.lookup)UV_THREADPOOL_SIZE=<n>./nodejs.md §6.1docs.libuv.org/en/v1.x/threadpool.html (default size is 4; global and shared across all event loops)libuv ≥ 1.30 (max 1024); Node v24documented
PL-ND-073Worker constructor + events (online/message/messageerror/error/exit); shared memory via SharedArrayBuffer; env copynew Worker(filename[, options])./nodejs.md §6.2worker_threads.html#new-workerfilename-options (added v10.5.0; non-experimental v12.11.0/v11.7.0; Stability 2)Node v24documented
PL-ND-074worker.terminate() returns Promise (since v12.5.0, async); worker.ref()/unref()worker.terminate() → Promise<integer>./nodejs.md §6.2worker_threads.html#workerterminatecallback (added v10.5.0; Promise v12.5.0); #workerref (v10.5.0)Node v24documented
PL-ND-075Worker ‘exit’ event semantics (passed code, or 1 if terminated; final event)worker.on('exit', (exitCode) => {})./nodejs.md §3.9, §6.2worker_threads.html#event-exit (added v10.5.0)Node v24documented
PL-ND-076Pipe backpressure deadlock (bounded kernel pipe buffer; drain all pipes or ‘ignore’/‘inherit’)—./nodejs.md §6.4ch. §6.4 (POSIX pipe(7) buffer + §3.3 stdout-async docs); contrast exec bufferingLinux/POSIX + Node v24documented
PL-ND-077fd ownership: streams closed at ‘close’; leak patterns (not draining, IPC never disconnected, detached w/o stdio:‘ignore’, kill() return ignored)—./nodejs.md §6.5ch. §6.5 (from child_process.html disconnect/unref/close contracts)Node v24documented
PL-ND-078MaxListenersExceededWarning (name/emitter/type/count; inspect via ‘warning’ event; defaultMaxListeners no effect on AbortSignal)process.on('warning', (w) => {})./nodejs.md §6.6events.html#eventsdefaultmaxlisteners (“maximum of 10 listeners”); warning name documented in events.htmlNode v24documented
PL-ND-079Races: ‘exit’→‘close’ order; error+exit double delivery; kill-before-‘spawn’ event; sync block defers signal handling; ‘beforeExit’ re-arm—./nodejs.md §6.7child_process.html#event-error/#event-spawn; cli/execSync blocking semantics (§5.7)Node v24documented
PL-ND-080GC plays no role in process cleanup (no finalizers; explicit kill/disconnect/destroy; ‘close’ as release checkpoint)—./nodejs.md §6.8ch. §6.8 (from documented close/disconnect/kill contracts)Node v24documented