Untitled Lesson
Skill Matrix
UNLOCK NODES BY LEARNING NEW TAGS.
In a microservices request flow, what is required for a correlation ID generated at the API gateway to actually help trace the request through a downstream service?
💻 Code Challenge | +75 XP
Implement middleware that generates or reuses an x-request-id header, creates a child logger bound to it, and forwards the same header on any outbound fetch calls made during that request.
A request traced through three microservices shows a correlation ID in the first service's logs, but the second service's logs have no matching ID at all. Reorder the steps to fix the propagation gap.
Task: Reorder the blocks in logical sequence to solve the problem.
A.D.A. Interface
Adaptive Didactic Assistant

Pascual Vila
Frontend Instructor // Code Syllabus
The Error //
Generating a correlation ID but forgetting to forward it as a header on outbound calls to downstream services
// Wrong: the ID never leaves this service
await fetch(downstreamUrl); // no correlation header forwarded
// Correct
await fetch(downstreamUrl, { headers: { "x-request-id": req.id } });The Solution //
A correlation ID that lives only in one service's own logs provides no value for tracing a request across a microservices architecture — the whole point is threading the same ID through every service the request touches. Explicitly include it as a header on every outbound HTTP call made while handling that request.
The Error //
Manually threading a request ID through every function parameter instead of using AsyncLocalStorage
// Tedious and error-prone: threading a parameter everywhere
function processOrder(order, requestId) { chargeCard(order, requestId); }
// Cleaner: AsyncLocalStorage makes it implicitly available
function processOrder(order) { chargeCard(order); } // requestId available via als.getStore()The Solution //
Passing req.id as an extra parameter through every function in a call chain is tedious, easy to forget in a new function, and clutters function signatures with a cross-cutting concern unrelated to their actual purpose. AsyncLocalStorage maintains the context implicitly across async operations without explicit parameter threading.