-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Prefer Fiber#storage
over copying thread locals
#5173
Comments
Hey, thanks for taking a look and sharing your concerns. The goal here is to retain compatibility with code that uses I just started using I'm also open to making this |
Risks:
|
Oh, I see, thanks for laying those out. In practice, copying the entries from Maybe that's the catch here: Database connections (etc) is an interesting case. Rails is the elephant in the room, and so far, the best approach has been to manually implement context sharing: https://graphql-ruby.org/dataloader/async_dataloader#activerecord-connections Have you run into real-world issues with copying context like this, in GraphQL-Ruby or elsewhere? |
Yes, and the problems are the same.
It's hard for me to pinpoint exact failures since they are often soft and/or transient (some requests may fail or behave incorrectly). While not directly related, an example of how context sharing can lead to incorrect execution: https://github.blog/security/vulnerability-research/how-we-found-and-fixed-a-rare-race-condition-in-our-session-handling/ Since it's entirely possible for things like There are probably situations where what you are doing is useful (as you've said for compatibility). If you are sure you control all fibers within a given thread, it might be safe. However, this code makes me extremely uncomfortable, so I strongly advise you to encourage Fiber storage for inheritable state. |
Moving GraphQL-Ruby's own I'm open to removing this default behavior from GraphQL-Ruby, so I'll keep this issue open until I get to try it out. |
I believe this code is extremely risky.
graphql-ruby/lib/graphql/dataloader.rb
Line 80 in 8a21eb1
The text was updated successfully, but these errors were encountered: