-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: Memoize AsyncLocalStorage
instance
#8831
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
Conversation
size-limit report 📦
|
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.
Hmm I'm not sure but wouldn't this mean we potentially reuse the same asyncLocalStorage instance across multiple requests which we actually want to isolate? Don't have a ton of context around ALS so not sure if this concern makes sense
Well yes, but that is theoretically not an issue. What matters is that I am trying to come up with a case where we might run into problems here, but I am struggling. I guess the baseline where this potentially messes up always involves calling |
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.
Thanks for explaining, this makes sense to me now! I'd say we give it a try and if the issue author is comfortable with trying this out locally first, it'd be even better.
TIL the leak is likely because |
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.
Wouldn't this stop us or customers from overriding the async strategy after it's been set by |
No sorry, I misundersttod the changes! |
Attempts to fix the memory leak reported in #8829 by memoizing the
AsyncLocalStorage
instance we create when setting the async context strategy.Note for reviewers: Can you think of any problems this may cause?