Skip to content

NoMethodError: undefined method `each' for nil #17

@histfak

Description

@histfak

I use Falcon with Sinatra and few times a day I see the following exception in the logs:

[2024-09-08 03:21:33] {"time":"2024-09-08T03:21:33+00:00","severity":"warn","oid":8160,"pid":5,"subject":"Async::Task","annotation":"Reading HTTP/1.1 requests for Async::HTTP::Protocol::HTTP1::Server.","message":"Task may have ended with unhandled exception.","event":{"type":"failure","root":"/usr/src/app","class":"NoMethodError","message":"\u001b[1mundefined method `each' for nil (\u001b[1;4mNoMethodError\u001b[m\u001b[1m)\u001b[m\n\n\u001b[1m\t\t\t\t\t@body.each(&block)\u001b[m\n\u001b[1m\t\t\t\t\t ^^^^^\u001b[m","backtrace":["/usr/local/bundle/ruby/3.3.0/gems/protocol-rack-0.7.0/lib/protocol/rack/body/enumerable.rb:71:in `each'","/usr/local/bundle/ruby/3.3.0/gems/protocol-http1-0.22.0/lib/protocol/http1/connection.rb:313:in `write_fixed_length_body'","/usr/local/bundle/ruby/3.3.0/gems/protocol-http1-0.22.0/lib/protocol/http1/connection.rb:401:in `write_body'","/usr/local/bundle/ruby/3.3.0/gems/async-http-0.75.0/lib/async/http/protocol/http1/server.rb:96:in `block in each'","/usr/local/bundle/ruby/3.3.0/gems/async-2.17.0/lib/async/task.rb:318:in `defer_stop'","/usr/local/bundle/ruby/3.3.0/gems/async-http-0.75.0/lib/async/http/protocol/http1/server.rb:57:in `each'","/usr/local/bundle/ruby/3.3.0/gems/async-http-0.75.0/lib/async/http/server.rb:50:in `accept'","/usr/local/bundle/ruby/3.3.0/gems/io-endpoint-0.13.1/lib/io/endpoint/wrapper.rb:182:in `block (2 levels) in accept'","/usr/local/bundle/ruby/3.3.0/gems/async-2.17.0/lib/async/task.rb:197:in `block in run'","/usr/local/bundle/ruby/3.3.0/gems/async-2.17.0/lib/async/task.rb:422:in `block in schedule'"]}}

No sure if this is just a bad request or bug. Ruby version is 3.3.4 and YJIT is enabled globally via RUBYOPT.

Falcon configuration:

# frozen_string_literal: true

load :rack

hostname = File.basename(__dir__)
service hostname do
  include Falcon::Environment::Rack
  count ENV.fetch('WORKERS', 1).to_i

  preload 'preload.rb'
  cache true

  endpoint do
    Async::HTTP::Endpoint.parse("http://0.0.0.0:#{ENV.fetch('PORT',
                                                            80)}").with(protocol: Async::HTTP::Protocol::HTTP11)
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions