publish date
Jun 8, 2022
duration
23
min
Difficulty
Case details
Preserving contextual data across asynchronous calls has been always tricky in Node.js land. For example, how to pass information about the current user or a correlation (transaction) id from the code processing incoming HTTP requests to the code calling a backend web service? Traditional runtimes like C and Java can utilize thread-local storage, which does not work for Node's single-threaded event loop. The talk will describe different solutions people have been using (and abandoning) over the past 6+ years, dive into the history of domains and async hooks, explain what's so difficult about context keeping. Finally, I'll discuss the AsyncLocalStorage API introduced by Node.js 14 and show how to use it in practice.
Share case: