Skip to content
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

NameError: uninitialized constant Rack::RACK_VERSION #33

Closed
deepj opened this issue Nov 6, 2018 · 7 comments
Closed

NameError: uninitialized constant Rack::RACK_VERSION #33

deepj opened this issue Nov 6, 2018 · 7 comments

Comments

@deepj
Copy link
Contributor

deepj commented Nov 6, 2018

When I run the following script:

run lambda {|env| [200, {}, ["Hello World"]]}

using

NIO4R_PURE=true falcon --verbose serve -c falcon.rb --threaded

Note: use it for testing falcon under Trufferuby

I got this issue under Ruby 2.5.3/Truffleruby 1.0.0-rc9 on macOS 10.14

D, [2018-11-06T20:52:24.014304 #38164] DEBUG -- Async::IO::Socket: Binding to #<Addrinfo: [::1]:9292 TCP (localhost)>
D, [2018-11-06T20:52:24.014689 #38164] DEBUG -- Async::IO::Socket: Binding to #<Addrinfo: 127.0.0.1:9292 TCP (localhost)>
D, [2018-11-06T20:52:24.014840 #38164] DEBUG -- <Async::Reactor:0x3fbf92cf4770 stopped=false>: Exiting run-loop because finished.
I, [2018-11-06T20:52:24.014951 #38164]  INFO -- : Falcon taking flight! Binding to #<Falcon::Endpoint https://localhost:9292/ {}> [Async::Container::Threaded with concurrency: 4]
I, [2018-11-06T20:52:24.015345 #38164]  INFO -- : Send `kill -USR1 38164` for detailed status :)
I, [2018-11-06T20:52:24.016304 #38164]  INFO -- : Send `kill -USR1 38164` for detailed status :)
I, [2018-11-06T20:52:24.015543 #38164]  INFO -- : Send `kill -USR1 38164` for detailed status :)
I, [2018-11-06T20:52:24.017282 #38164]  INFO -- : Send `kill -USR1 38164` for detailed status :)
E, [2018-11-06T20:52:33.333196 #38164] ERROR -- #<Async::IO::SSLServer:0x00007f7f259c8d20>: SSL_accept returned=1 errno=0 state=unknown state: sslv3 alert bad certificate (OpenSSL::SSL::SSLError)
~/.gem/ruby/2.5.3/gems/async-io-1.16.3/lib/async/io/generic.rb:128:in `accept_nonblock'
~/.gem/ruby/2.5.3/gems/async-io-1.16.3/lib/async/io/generic.rb:128:in `async_send'
~/.gem/ruby/2.5.3/gems/async-io-1.16.3/lib/async/io/generic.rb:47:in `block in wrap_blocking_method'
~/.gem/ruby/2.5.3/gems/async-io-1.16.3/lib/async/io/ssl_socket.rb:126:in `block in accept'
~/.gem/ruby/2.5.3/gems/async-1.10.3/lib/async/task.rb:74:in `block in initialize'
D, [2018-11-06T20:52:48.613432 #38164] DEBUG -- Async::HTTP::Protocol::HTTPS: Negotiating protocol "h2"...
D, [2018-11-06T20:52:48.615964 #38164] DEBUG -- #<Falcon::Server:0x00007f7f259c8e88>: Incoming connnection from #<Addrinfo: [::1]:50229 TCP> to #<Async::HTTP::Protocol::HTTP2::Server:0x00007f7f259aba18>
D, [2018-11-06T20:52:48.616093 #38164] DEBUG -- localhost:9292: GET / HTTP/2.0 from #<Addrinfo: [::1]:50229 TCP>
E, [2018-11-06T20:52:48.618435 #38164] ERROR -- : NameError: uninitialized constant Rack::RACK_VERSION
Did you mean?  RUBY_VERSION
	~/.gem/ruby/2.5.3/gems/falcon-0.19.2/lib/falcon/adapters/rack.rb:92:in `call'
	~/.gem/ruby/2.5.3/gems/async-http-0.37.0/lib/async/http/middleware.rb:57:in `call'
	~/.gem/ruby/2.5.3/gems/falcon-0.19.2/lib/falcon/adapters/rewindable.rb:61:in `call'
	~/.gem/ruby/2.5.3/gems/async-http-0.37.0/lib/async/http/middleware.rb:57:in `call'
	~/.gem/ruby/2.5.3/gems/async-http-0.37.0/lib/async/http/content_encoding.rb:44:in `call'
	~/.gem/ruby/2.5.3/gems/async-http-0.37.0/lib/async/http/middleware.rb:57:in `call'
	~/.gem/ruby/2.5.3/gems/falcon-0.19.2/lib/falcon/verbose.rb:50:in `call'
	~/.gem/ruby/2.5.3/gems/async-http-0.37.0/lib/async/http/middleware.rb:57:in `call'
	~/.gem/ruby/2.5.3/gems/async-http-0.37.0/lib/async/http/server.rb:63:in `block in accept'
	~/.gem/ruby/2.5.3/gems/async-http-0.37.0/lib/async/http/protocol/http2/server.rb:63:in `each'
	~/.gem/ruby/2.5.3/gems/async-http-0.37.0/lib/async/http/server.rb:52:in `accept'
	~/.gem/ruby/2.5.3/gems/async-io-1.16.3/lib/async/io/socket.rb:68:in `block in accept_each'
	~/.gem/ruby/2.5.3/gems/async-io-1.16.3/lib/async/io/ssl_socket.rb:128:in `block in accept'
	~/.gem/ruby/2.5.3/gems/async-1.10.3/lib/async/task.rb:74:in `block in initialize'

I used Firefox to open the "page".

@ioquatix
Copy link
Member

ioquatix commented Nov 6, 2018

It should be referring to these constants and more...

https://github.com/rack/rack/blob/7eebdd63ab3e7f890a13eb127ccf28cc31d7d505/lib/rack.rb#L63

I wonder why it's not loading them.

@ioquatix
Copy link
Member

ioquatix commented Nov 6, 2018

Okay, I could reproduce the issue... hold on.

@deepj
Copy link
Contributor Author

deepj commented Nov 6, 2018

The above code fails with newest 0.19.3 on this error

falcon/adapters/rack.rb:40:in `initialize': App must be callable! (ArgumentError)

^^ @ioquatix

@ioquatix
Copy link
Member

ioquatix commented Nov 6, 2018

Yeah, don't use -c falcon.rb because it actually tries to load lib/falcon/falcon.rb which returns a module. I don't know why it's doing that, but it's somewhere in the guts of rack. Please ensure you use config.ru for now.

@ioquatix
Copy link
Member

ioquatix commented Nov 6, 2018

I added that argument error because I ran into that and I wanted it to fail during construction not use.

@deepj
Copy link
Contributor Author

deepj commented Nov 6, 2018

@ioquatix thx for the explanation and the help. I can run it under truffleruby. Unfortunately, when I want to open the page, it fails on something Truffleruby internal error :) I'm going to report it.

@ioquatix
Copy link
Member

ioquatix commented Nov 6, 2018

Okay, I found out why it has funny behaviour.

https://github.com/rack/rack/blob/master/lib/rack/builder.rb#L36-L51

If you do Rack::Builder.parse_file('falcon.rb') it executes require 'falcon.rb' and returns Object.const_get('Falcon'). Wow. That's surprising.

ioquatix added a commit to ioquatix/rack that referenced this issue Nov 6, 2018
This caused unexpected behaviour.

socketry/falcon#33 (comment)

When the user specified `falcon.rb` as the config file, it loaded code
from the gem rather than the local directory. This allows users to bypass
this "feature" by directly using `Builder.load_file` which doesn't try
to `require` the path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants