rmosolgo/graphql-ruby

Fiber dependency is making all requests fail on Rails 7.0

elie-lawfty opened this issue · 4 comments

Describe the bug

Sunddenly getting

NoMethodError:
undefined method `[]=' for Fiber:Class              

for all graphql requests

Versions

graphql version: 2.3.11
rails (or other framework): 7.0 (postgres db)
other applicable versions (graphql-batch, etc)

GraphQL schema

GraphQL query

Steps to reproduce

Any graphql query to our rails or tests going through Schema.execute

Expected behavior

Execution success

Actual behavior

NoMethodError:
undefined method `[]=' for Fiber:Class              

Place full backtrace here (if a Ruby exception is involved):

 1)                                                                                                                     
Failure/Error: result = Schema.execute(query, variables: variables, context: context, operation_name: operation_name)

     NoMethodError:
       undefined method `[]=' for Fiber:Class
     Shared Example Group: "redacted" called from ./spec/api_2.0/mutations/redacted_spec.rb:33
     # /usr/share/rvm/gems/ruby-2.7.8/gems/graphql-2.3.11/lib/graphql/execution/interpreter.rb:37:in `run_all'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/graphql-2.3.11/lib/graphql/schema.rb:1364:in `multiplex'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/graphql-2.3.11/lib/graphql/schema.rb:1340:in `execute'
     # ./app/controllers/api/v2/graphql_controller.rb:30:in `execute'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-attack-6.7.0/lib/rack/attack.rb:103:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-attack-6.7.0/lib/rack/attack.rb:110:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/remotipart-1.3.1/lib/remotipart/middleware.rb:32:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/warden-1.2.9/lib/warden/manager.rb:36:in `block in call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/warden-1.2.9/lib/warden/manager.rb:34:in `catch'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/warden-1.2.9/lib/warden/manager.rb:34:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/tempfile_reaper.rb:15:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/etag.rb:27:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/conditional_get.rb:40:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/head.rb:12:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/session/abstract/id.rb:266:in `context'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/session/abstract/id.rb:260:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/railties-7.0.8.4/lib/rails/rack/logger.rb:40:in `call_app'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/railties-7.0.8.4/lib/rails/rack/logger.rb:25:in `block in call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/railties-7.0.8.4/lib/rails/rack/logger.rb:25:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/request_store-1.7.0/lib/request_store/middleware.rb:19:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/method_override.rb:24:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/runtime.rb:22:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-2.2.9/lib/rack/sendfile.rb:110:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-cors-1.1.1/lib/rack/cors.rb:100:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/railties-7.0.8.4/lib/rails/engine.rb:530:in `call'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-test-2.1.0/lib/rack/test.rb:360:in `process_request'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rack-test-2.1.0/lib/rack/test.rb:153:in `request'
     # /usr/share/rvm/gems/ruby-2.7.8/gems/rails-controller-testing-1.0.5/lib/rails/controller/testing/integration.rb:16:in `block (2 levels) in <module:Integration>'
     # ./spec/support/helpers/graphql.rb:24:in `execute_gql'

Finished in 1.34 seconds (files took 3.73 seconds to load)
1 example, 1 failure

Additional context

Adding gem "fiber-storage" to our Gemfile fixes the issue but we shouldn't have to since it's a dependency of this gem and not our codebase.

With these details, we can efficiently hunt down the bug!

Hey, sorry for the trouble! Thanks for the detailed report.

Oh, I see that Fiber::[] was added in Ruby 3.2. I'll have to add that polyfill gem as a dependency.

Hey hey same with our spec suite at sentry-ruby, downgrading to before 2.3.11 made our spec suite green again

Hey everyone, thanks again for reporting this and sorry for the trouble.

I missed this in CI because my builds with Ruby < 3.2 also had the async gem which had fiber-storage as a dependency. So, I added a CI build without async on Ruby 2.7. Hopefully that will help me avoid compatibility issues in the future.

I added fiber-storage as a dependency in #5052 and just released graphql-ruby v2.3.12 with that fix. Please let me know if you run into any more trouble with it!