Syntax - Tasty Web Development Treats cover image

Syntax - Tasty Web Development Treats

AsyncLocalStorage + AsyncContext API

Jun 19, 2023
17:30
Snipd AI
Scott and Wes explore the world of AsyncLocalStorage and AsyncContext API, discussing their potential in sharing context among the call stack, middleware applications, and frameworks like Next.js and Cloudflare Workers. They also provide examples of usage and caution against potential footguns.
Read more

Podcast summary created with Snipd AI

Quick takeaways

  • AsyncLocalStorage allows you to define a store inside a function, making it easier to share data between function calls without manual passing of references or values.
  • Many frameworks are not yet using AsyncLocalStorage widely due to its reliance on a Node.js API, but a proposal for an async context API in JavaScript could offer similar functionality across all runtimes.

Deep dives

Async Local Storage in JavaScript

Async local storage is a new API in JavaScript that allows you to define a store inside a function, which can be accessed anywhere down the call stack. It provides a way to share data between multiple function calls without passing references or values manually. It is particularly useful for logging and tracing request IDs, user sessions, and user preferences. It can also simplify console logging by storing data like show numbers and accessing it in different functions. However, using async local storage may present some challenges, such as testing and potential memory leaks if not handled properly.

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode