Skip to content
academia.sh

Course Intermediate

Asynchronous JavaScript and the Runtime

By the end of this course

Start course

01

Execution Model

The consequences of single-threaded execution; the event loop's call stack and task and microtask queues; what timers actually mean; and callback-based asynchrony.

  1. 01 The Single-Threaded Model JavaScript's single-threaded, run-to-completion execution model; the consequences of blocking work; the boundary between the language's core and the asynchronous abilities the runtime provides.
  2. 02 The Event Loop The distinction between the call stack, the task queue, and the microtask queue; the event loop's turn rule; justifying a mixed example's output order line by line.
  3. 03 Timers The delay as a lower bound, the order of equal-delay timers, drift and overlap in interval scheduling, the self-scheduling loop, and cancellation.
  4. 04 Callbacks The error-first callback contract, setting up sequential and combined processing by hand, the nesting problem, and the uncertainties that come from handing control to the callee.

02

Promises and async/await

A promise's state machine and chaining rules, waiting in parallel with combinators, the async/await syntactic layer, asynchronous error propagation, and asynchronous iteration.

  1. 01 The Promise Concept A promise's three-state machine, the result being decided exactly once, callbacks being deferred to a microtask, and each step of chaining producing a new promise.
  2. 02 Promise Combinators Four combinators that gather multiple promises into a single promise; their differing behavior in the face of errors; the distinction between when work starts and when it is awaited.
  3. 03 async/await An async function always returning a promise, await suspending the function, the syntactic layer's correspondence to a promise chain, and the bug of falling into unintentional sequential waiting.
  4. 04 Asynchronous Error Handling Rejection propagating through the chain, the points where try/catch and catch syntax diverge, the loss of error information, the cause chain, and tracking unhandled rejections.
  5. 05 Asynchronous Iteration The asynchronous iterator protocol, the for await loop, asynchronous generators, cleanup on early exit, and pull-based streams' advantage against backpressure.

03

Network and Data Access

Request and response objects, streaming bodies, controlling request lifetime with an abort signal, timeouts, and retry patterns for transient errors.

  1. 01 HTTP Requests The structure of request and response objects, why a status code is not treated as an error, the body being readable only once, and processing a streaming body chunk by chunk with asynchronous iteration.
  2. 02 Cancellation and Timeouts The abort signal concept, actually stopping a request, building a timeout on top of the signal, why a race-based timeout falls short, and combining signals.
  3. 03 Error and Retry Patterns Separating transient errors from permanent ones, retrying with growing wait times, the retry budget, idempotence through an operation key, and preventing mass failure.

04

Memory and Performance

The allocation and release cycle of memory, reachability-based garbage collection, leak diagnosis by snapshot comparison, main-thread profiling, and debugging tools.

  1. 01 Memory Lifecycle The phases of allocation, use, and release; reachability's root set; what timers, listeners, and unsettled promises hold onto in memory in asynchronous code.
  2. 02 Garbage Collection How reachability-based collection works, why reference counting fails on cycles, the generational hypothesis, incremental collection's pauses, and weak-reference structures.
  3. 03 Diagnosing Memory Leaks A leak defined as unwanted reachability, four common sources in asynchronous code, what a heap snapshot contains, and the method of counting accumulation by comparing two snapshots.
  4. 04 Performance Profiling Reading the main thread's timeline, the concept of a long task, event loop lag, what a sampling profiler records, and the observable effect of splitting a long job and yielding turns.
  5. 05 Debugging Tools Connecting to the debugging interface, breakpoints and conditional breaks, watch expressions, stepping, and reading asynchronous call stacks.

Start typing to search.

↑↓ Esc navigate · open · close