Skip to content
academia.sh

Course Advanced

The Node.js Runtime

By the end of this course

Start course

01

Runtime Model

The capability differences between the browser and the server runtime, the event loop's phases, the process object, and the rules of module resolution.

  1. 01 Differences from the Browser The host environment concept, the global object's contents, the two module systems coexisting, and the server runtime's capability boundaries.
  2. 02 Event Loop Phases The loop's phase order, the difference between the timers and check phases, when the two microtask queues drain, and the measurable cost of blocking work.
  3. 03 The Process Object The argument array, environment variables, the object counterpart of the standard streams, the two ways to set an exit code, and the exit hook.
  4. 04 Module Resolution The three specifier types, the file-extension requirement, the package directory search chain, the exports map, and querying resolution from the program.

02

Built-in Modules

The file system, path operations, streams, buffers, the event emitter, the HTTP server, child processes, and clustering with worker threads.

  1. 01 File System The difference between three interfaces offering the same work, the role of the thread pool, branching on error codes, directory operations, and updating a file without ever leaving it half-written.
  2. 02 Path Operations Joining and resolving path parts, platform rules offered separately, anchoring from the script's own location, and preventing an escape outside the root directory.
  3. 03 Streams The four stream types, why chunk boundaries do not line up with record boundaries, object mode, building a pipeline, and measuring backpressure.
  4. 04 Buffers How a raw byte array differs from a string, zeroed versus unzeroed allocation, the view-versus-copy distinction, the problem of splitting at a character boundary, and binary record encoding.
  5. 05 Event Emitter The built-in implementation of the observer pattern, the synchrony of emission, the error event's special behavior, the max-listeners warning, and awaiting events in promise form.
  6. 06 HTTP Server The stream counterpart of request and response objects, dispatch by path and method, a size limit on reading the body, and the choice between declaring a length and chunked transfer.
  7. 07 Child Processes Two ways to run an external command, the risk brought by the shell layer, the distinction between an exit code and a terminating signal, and passing messages between runtime processes.
  8. 08 Cluster and Worker Threads A process cluster sharing the same port, a worker thread's memory model, which kind of work each approach fits, and the measured difference in blocking.

03

Writing Applications

Command-line tools, separating configuration from secrets, error handling strategy, structured logging, testing, debugging, graceful shutdown, and package publishing.

  1. 01 Command-Line Applications Option parsing, taking input from a file or a pipeline, checking terminal attachment, writing the usage text to the right stream, and meaningful exit codes.
  2. 02 Configuration Management Separating settings from source code, validating environment variables, precedence order, separating secrets from ordinary settings, and keeping configuration immutable.
  3. 03 Error Handling Strategy The distinction between operational errors and programmer errors, chaining error causes, the forms of asynchronous errors that escape catching, and the correct use of last-resort hooks.
  4. 04 Logging Structured records instead of free text, level thresholds, carrying optional fields, writing the log to standard output, and inspecting records with tools.
  5. 05 Test The built-in test runner, the boundary of a unit test, writing integration tests by separating the server from listening, a failing test's output, and reading the coverage report.
  6. 06 Debugging and Profiling Opening the inspector protocol, the fields of memory usage, heap snapshots, reading a CPU profile, and in-code duration measurement.
  7. 07 Process Management and Resilience Catching signals, the phases of graceful shutdown, the distinction between liveness and readiness probes, the restart contract, and bounding shutdown duration.
  8. 08 Package Publishing The export contract of the package manifest, conditional entries, hiding internal paths, the executable entry point, and pre-publish checks.

Start typing to search.

↑↓ Esc navigate · open · close