Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_code-typescript-event-loop-and-microtasks

TypeScript / Node.js Event Loop, Microtasks & libuv Threadpool

6 COMPONENTS · 6 FLOWS · UPDATED 2026-11-24
GITHUB README / PR PREVIEW CARD
[![TypeScript / Node.js Event Loop, Microtasks & libuv Threadpool — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_code-typescript-event-loop-and-microtasks/opengraph-image)](https://archos.sageideas.dev/d/dgm_code-typescript-event-loop-and-microtasks)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_code-typescript-event-loop-and-microtasks)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_code-typescript-event-loop-and-microtasks" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="TypeScript / Node.js Event Loop, Microtasks & libuv Threadpool — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  client_0["JS / TS Request"]
  n1_1["V8 Call Stack"]
  n2a_2[("Microtask Queue")]
  n2b_3[("libuv Phase Queues")]
  n3_4["libuv Worker Pool"]
  downstream_5["Downstream & OTel"]
  client_0 -->|"1. Push frame · V8"| n1_1
  n1_1 -->|"2a. Drain 100% · Microtas"| n2a_2
  n1_1 -->|"2b. IO · libuv"| n2b_3
  n2a_2 -->|"3a. Thread · UV_POOL"| n3_4
  n2b_3 -->|"3b. Merge · RAM"| n3_4
  n3_4 -.->|"4. Emit / · OTLP/API"| downstream_5

COMPONENT STACK (6)

  • JS / TS RequestSTATELESS
    Async Promises & I/O
  • V8 Call StackSTATELESS
    Single-thread JS execution
  • Microtask QueueSTATEFUL
    Promise.then / queueMicrotask
  • libuv Phase QueuesSTATEFUL
    Timers, Poll & Check
  • libuv Worker PoolSTATELESS
    4 threads for fs/dns/crypto
  • Downstream & OTelSTATELESS
    Consumers, metrics & SLOs

REQUEST & DATA FLOW (6)

  1. JS / TS Request → V8 Call Stack (Push frame)[V8]
  2. V8 Call Stack → Microtask Queue (Drain 100%)[Microtas]
  3. V8 Call Stack → libuv Phase Queues (IO)[libuv]
  4. Microtask Queue → libuv Worker Pool (Thread)[UV_POOL]
  5. libuv Phase Queues → libuv Worker Pool (Merge)[RAM]
  6. libuv Worker Pool → Downstream & OTel (Emit /)[OTLP/API]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →