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 is AsyncLocalStorage named this way instead of something like Context or ContextObject in Node.js? #57067

Closed
diyorbekrustamjonov opened this issue Feb 15, 2025 · 3 comments
Labels
doc Issues and PRs related to the documentations. question Issues that look for answers.

Comments

@diyorbekrustamjonov
Copy link

Affected URL(s)

https://nodejs.org/api/async_context.html

Description of the problem

I'm curious about the naming of AsyncLocalStorage in Node.js. In Go, for example, there's a context standard library, which feels more intuitive when dealing with asynchronous context management. However, in Node.js, the API is named AsyncLocalStorage.

Why was this name chosen instead of something more straightforward like Context or ContextObject similar? Some developers find the current naming confusing or even misleading, as it doesn't immediately convey the idea of managing asynchronous execution context.

Is there any historical or technical reason behind this naming choice? Would it be possible to align with a more conventional term like Context or AsyncContext, which might be clearer for developers familiar with similar patterns in other languages?

@diyorbekrustamjonov diyorbekrustamjonov added the doc Issues and PRs related to the documentations. label Feb 15, 2025
@jasnell
Copy link
Member

jasnell commented Feb 15, 2025

The naming was chosen to align conceptually with the term "thread local storage" and it wouldn't be practical or helpful to the ecosystem as a whole to rename it at this point.

@Qard
Copy link
Member

Qard commented Feb 16, 2025

Also, changing the name to AsyncContext would conflict with the TC39 proposal of the same name. That even does the same thing (roughly) so the API mismatch would be very bad for standards adherence.

@joyeecheung joyeecheung added the question Issues that look for answers. label Feb 20, 2025
@joyeecheung
Copy link
Member

Closing because it is just a question and it’s answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

4 participants