Continuation Local Storage for easy context passing in Node.js

Roman Coedo
Oct 14, 2019 · 2 min read
Photo by Suad Kamardeen on Unsplash

Recently I’ve been working on a Node.js project where we needed to keep track of which requests were generating calls to some other pieces of code. Passing a request identifier around was not viable since it would require to change too many APIs.

We solved the problem using cls-hooked, a small package that uses the async_hooks experimental Node.js API to…