-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add frameworks use cases #117
Conversation
a34b492
to
19d020f
Compare
19d020f
to
844e7d5
Compare
Note: ALS is also widely used in Next.js for various features (cookies(), headers(), after() and more) Also an interesting "future of React" tweet worth asking the team about? (now deleted, unfortunately) |
All those Next.js features are server-side, right? I'm trying to include frontend examples from all frameworks since it's the browsers we have to convince :) |
--> | ||
|
||
> The Svelte team are eagerly awaiting the day we can use `AsyncContext`. The widespread adoption of `AsyncLocalStorage` across different packages (and runtimes, despite its non-standard status) is clear evidence that real use cases exist; there is no a priori reason to assume that those use cases are restricted to server runtimes, and indeed there are two concrete examples where our hands are currently tied by the lack of this capability in the browser: **[server]** we're introducing a `getRequestEvent` function in SvelteKit that allows functions on the server to read information about the current request context (including things like the requested URL, cookies, headers etc), even if the function isn't called synchronously (which is necessary for it to be generally useful). | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rich-Harris what's the plan to remove the .enterWith()
call SvelteKit have in https://github.com/sveltejs/kit/blob/ee214121cb0ae38824c29b25ab36ef48e754705b/packages/kit/src/exports/vite/dev/index.js#L561? This kind of pattern would not be available with AsyncContext
(as the spec is currently defined, Svelte would need to refactor to use a run()
callback in AsyncLocalStorage
lingo).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll cross that bridge when we come to it — assuming AsyncLocalStorage
isn't immediately removed from Node if/when AsyncContext
lands we have years before we need to worry about it. The codebase could look entirely different by then, so no need to spend any cycles on it now.
For clarity, this bit isn't new — the feature I mention in the comment was added in sveltejs/kit#13582 and lives in this file, and it uses .run(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea if AsyncLocalStorage and AsyncContext can coexist and have different semantics. From a maintenance point of view maintaining both looks hard.
Marking as draft because we are still waiting on a quote-style explanation from React & Angular.
They are all sorted alphabetically, because I tried choosing which framework is the best to put it first and failed 😛