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

Initial draft of AsyncLocalStorage interoperable subset #38

Merged
merged 5 commits into from
Jan 27, 2023

Conversation

jasnell
Copy link
Contributor

@jasnell jasnell commented Jan 26, 2023

No description provided.

asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
Copy link

@littledan littledan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This document looks great! I just have a couple suggestions for clarity inline.

It'd be good if this document had an introduction explaining its rationale for existing, its relationship to AsyncContext, and how we hope that this will be a transitional subset rather than the recommended API forever.

asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
Copy link

@Qard Qard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think AsyncResource is a bit of a code smell with how much of it is not actually relevant to AsyncLocalStorage. Can we add AsyncLocalStorage.bind(...) as a wrapper for the Node.js use of it to abstract away those additional irrelevant bits? The way this is written now closely matches how Node.js works currently but I think it should be fine to deviate a bit for the sake of a cleaner interface to share between runtimes.

asynclocalstorage.md Outdated Show resolved Hide resolved
@jasnell
Copy link
Contributor Author

jasnell commented Jan 26, 2023

@Qard:

Can we add AsyncLocalStorage.bind(...) as a wrapper for the Node.js use of it to abstract away those additional irrelevant bits?

Let's separate this conversation. I have some concerns about the feasibility of per-AsyncLocalStorage propagation rules given the O(n) complexity that introduces.

@Qard
Copy link

Qard commented Jan 27, 2023

Per-storage binding we can put aside, but I think a global bind would be suitable as a direct equivalent to AsyncResource, and matches what AsyncContext proposed with its wrap function.

asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
asynclocalstorage.md Outdated Show resolved Hide resolved
@jasnell
Copy link
Contributor Author

jasnell commented Jan 27, 2023

@Qard :

Per-storage binding we can put aside, but I think a global bind would be suitable as a direct equivalent to AsyncResource, and matches what AsyncContext proposed with its wrap function.

Let's take discussion about adding an AsyncLocalStore.bind(...) to a Node.js issue or PR. I'm in favor if the semantics are really just an alias for AsyncResource.bind(...) but I think there are a few other details to consider before we can replace AsyncResource and it's just better to discuss those details over there.

@jasnell
Copy link
Contributor Author

jasnell commented Jan 27, 2023

Given that I think we have reasonable agreement on the basic API itself, I'm going to go ahead and merge this and we can continue to tweak as necessary with individual PRs

@jasnell jasnell merged commit be9db40 into main Jan 27, 2023
@jasnell jasnell deleted the asynclocalstorage branch January 27, 2023 18:19
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

Successfully merging this pull request may close these issues.

None yet

5 participants