Conversation
jplhomer
commented
Mar 23, 2023
| const articles = await Article.with("user").orderBy("createdAt", "desc"); | ||
| const articles = await Article.with("user") | ||
| .orderBy("createdAt", "desc") | ||
| .get(); |
Owner
Author
There was a problem hiding this comment.
A limitation with ALS in CF Workers today is that custom thenables don't properly retain context: https://twitter.com/jasnell/status/1634764772121145344
Owner
Author
There was a problem hiding this comment.
| @@ -1,4 +1,5 @@ | |||
| import { marked } from "marked"; | |||
| // TODO: Find a lighter solution for syntax highlighting | |||
Owner
Author
There was a problem hiding this comment.
Not related to ALS per se, but my CF Workers bundle is like 4MB because of this 🙃
| /** | ||
| * We inject env and session into the Remix load context. | ||
| * Someday, we could replace this with AsyncLocalStorage. | ||
| * TODO: REMOVE THIS since we're using AsyncLocalStorage |
Contributor
There was a problem hiding this comment.
For me, I think I'll still put some separate things in the context for now. But a lot of people probably never should need to care about context.
| return await asyncLocalStorage.run({}, async () => { | ||
| /** | ||
| * I'm being extra cautious to not set the object value until we're _inside_ the asyncLocalStorage.run | ||
| * closure. This is to prevent accidental leaks between requests. I don't know if it's necessary. |
Owner
Author
There was a problem hiding this comment.
TODO: Verify whether this is necessary or if I can just populate an object outside of the run.
Contributor
|
👀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that Cloudflare supports ALS using the
nodejs_compatcompatibility flag, this allows us to attach Superflare config to a request-local context. This is way better than assigning a bunch of variables to a global singleton because:SessionandRequestandAuthThis means we can start providing helpers like
session()andauth(), and use them from within Superflare internals as well 🎉We've been waiting on a patch to Remix which just landed in
devremix-run/remix#5773TODO: