puzpuzpuz / cls-rtracer

Request Tracer - CLS-based request id generation for Express, Fastify, Koa and Hapi, batteries included
MIT License
311 stars 24 forks source link

Migrate to core CLS API (AsyncLocalStorage) #26

Closed puzpuzpuz closed 4 years ago

puzpuzpuz commented 4 years ago

2.0.0 (or an experimental version of the library) could start using AsyncLocalStorage instead of cls-hooked: https://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage

That should be done once AsyncLocalStorage is backported to Node.js v12.

SimenB commented 4 years ago

You of course know this already, but AsyncLocalStorage is available in v12.17. Do you have any timeline for when you'll be able to start experimenting with it?

puzpuzpuz commented 4 years ago

@SimenB yes, I know about the release. The migration should be pretty straightforward. I'm going to start it this or the next week.

puzpuzpuz commented 4 years ago

@SimenB v2.0.0 which based on AsyncLocalStorage is now available on npm. Please let me know if you face any issues.

SimenB commented 4 years ago

Thank you! We've had some issue losing context in prod using v1 - just upgraded and will report back if it makes any difference 👍

puzpuzpuz commented 4 years ago

@SimenB please report the issue if it remains. I'll do my best to help.

SimenB commented 4 years ago

Thanks @puzpuzpuz! Deployed to prod a couple of hours ago, and it's looking good so far! The cases I knew where we lost context seems fixed now. I'll check throughout the week if there are any cases we're missing