Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why not using node internal AsyncLocalStorage? #52

Open
tofixx opened this issue Nov 17, 2020 · 2 comments
Open

why not using node internal AsyncLocalStorage? #52

tofixx opened this issue Nov 17, 2020 · 2 comments

Comments

@tofixx
Copy link

tofixx commented Nov 17, 2020

The current node lts supports using internal async_hooks which does not break in some reasons, cls-hooks fails.

The middleware could use https://nodejs.org/docs/latest-v14.x/api/async_hooks.html#async_hooks_asynclocalstorage_run_store_callback_args instead.

@PhakornKiong
Copy link

@tofixx May i know how cls-hook is failing? Technically it is based on the same async-hooks (for nodejs ver 8+) and it should works (There are some small bugs in ns.runPromise and how memory usage is not optimized), although the API is not consistent with that of ALS.

I'm in favor for using ALS as it is optimized in V8 layer. Some microbenchmarking results here
https://github.com/Darkripper214/ALS-CLS-Benchmark

@skonves
I've came up with a consistent async-context package that supports v 8.12 onwards and will use Nodejs' AsyncLocalStorage when needed. It also supports the legacy methods that cls-hooked have as well. Are you open to migration?
https://github.com/Darkripper214/ALS-Context

@dhalbrook
Copy link

dhalbrook commented Jan 19, 2022

The asynchronous-local-storage package has a very similar API to this one and uses AsyncLocalStorage if that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants