socketry / falcon

A high-performance web server for Ruby, supporting HTTP/1, HTTP/2 and TLS.
https://socketry.github.io/falcon/
MIT License
2.54k stars 79 forks source link

Falcon 0.44 broken when used with Rack 2 #230

Closed adam12 closed 3 months ago

adam12 commented 3 months ago

Something recent, since it was working before.

# config.ru
run ->(env) { [200, {}, ["OK"]] }
# Gemfile
source "https://rubygems.org"

gem "rack", "~> 2.0"
gem "falcon", "~> 0.44.0"
 0.05s     warn: Async::Task [oid=0x9d8] [ec=0x9ec] [pid=17166] [2024-04-02 13:22:49 -0400]
               | Task may have ended with unhandled exception.
               |   ArgumentError: App must be callable!
               |   → /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-rack-0.4.1/lib/protocol/rack/adapter/generic.rb:25 in `initialize'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-rack-0.4.1/lib/protocol/rack/adapter/rack2.rb:21 in `new'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-rack-0.4.1/lib/protocol/rack/adapter/rack2.rb:21 in `wrap'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-rack-0.4.1/lib/protocol/rack/adapter.rb:21 in `new'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-http-0.26.1/lib/protocol/http/middleware/builder.rb:18 in `block in use'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-http-0.26.1/lib/protocol/http/middleware/builder.rb:26 in `block in to_app'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-http-0.26.1/lib/protocol/http/middleware/builder.rb:26 in `each'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-http-0.26.1/lib/protocol/http/middleware/builder.rb:26 in `inject'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-http-0.26.1/lib/protocol/http/middleware/builder.rb:26 in `to_app'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/protocol-http-0.26.1/lib/protocol/http/middleware/builder.rb:35 in `build'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/falcon-0.44.0/lib/falcon/server.rb:24 in `middleware'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/falcon-0.44.0/lib/falcon/environment/rackup.rb:22 in `middleware'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/async-service-0.10.0/lib/async/service/environment.rb:108 in `block (2 levels) in wrap'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/falcon-0.44.0/lib/falcon/service/server.rb:60 in `block (2 levels) in setup'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/async-2.10.1/lib/async/task.rb:163 in `block in run'
               |     /Users/adam/.local/share/mise/installs/ruby/3.3.0/lib/ruby/gems/3.3.0/gems/async-2.10.1/lib/async/task.rb:376 in `block in schedule'

Diff from updating. Working to broken.

diff --git a/Gemfile.lock b/Gemfile.lock
index 8974f97..2e6b6c2 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -57,17 +57,17 @@ GIT
 GEM
   remote: https://rubygems.org/
   specs:
-    async (2.9.0)
+    async (2.10.1)
       console (~> 1.10)
       fiber-annotation
       io-event (~> 1.5, >= 1.5.1)
       timers (~> 4.1)
-    async-container (0.16.13)
+    async-container (0.18.0)
       async
       async-io
     async-dns (1.3.0)
       async-io (~> 1.15)
-    async-http (0.63.0)
+    async-http (0.64.0)
       async (>= 1.25)
       async-io (>= 1.28)
       async-pool (>= 0.2)
@@ -77,19 +77,21 @@ GEM
       traces (>= 0.10.0)
     async-http-cache (0.4.3)
       async-http (~> 0.56)
-    async-io (1.41.0)
+    async-io (1.42.0)
       async
     async-pool (0.4.0)
       async (>= 1.25)
+    async-service (0.10.0)
+      async
+      async-container (~> 0.16)
     bake (0.19.0)
       bigdecimal
       samovar (~> 2.1)
     bcrypt (3.1.20)
     bigdecimal (3.1.6)
-    build-environment (1.13.0)
     cgi (0.4.1)
     concurrent-ruby (1.2.3)
-    console (1.23.5)
+    console (1.23.6)
       fiber-annotation
       fiber-local
       json
@@ -107,13 +109,13 @@ GEM
     erb (4.0.4)
       cgi (>= 0.3.3)
     erubi (1.12.0)
-    falcon (0.43.0)
+    falcon (0.44.0)
       async
-      async-container (~> 0.16.0)
+      async-container (~> 0.17)
       async-http (~> 0.57)
       async-http-cache (~> 0.4.0)
       async-io (~> 1.22)
-      build-environment (~> 1.13)
+      async-service (~> 0.10.0)
       bundler
       localhost (~> 1.1)
       openssl (~> 3.0)
@@ -178,7 +180,7 @@ GEM
     psych (5.1.2)
       stringio
     public_suffix (5.0.4)
-    rack (2.2.8.1)
+    rack (2.2.9)
     rack-attack (6.7.0)
       rack (>= 1.0, < 4)
     rack-mini-profiler (3.3.1)
@@ -192,7 +194,7 @@ GEM
       io-console (~> 0.5)
     rexml (3.2.6)
     ruby2_keywords (0.0.5)
-    samovar (2.2.0)
+    samovar (2.3.0)
       console (~> 1.0)
       mapping (~> 1.0)
     sentry-ruby (5.17.0)
adam12 commented 3 months ago

I'll see if I can fix.

trevorturk commented 3 months ago

I'm running into the same issue (Rack locked to v2 via other gem dependencies, I just noticed!)

ioquatix commented 3 months ago

I will release a fix shortly.

ioquatix commented 3 months ago

It looks like I accidentally dropped the workflow tests for older versions of Rack, which is how this slipped through. I've fixed that, and also added an interface to protocol-rack which is a better place to have the version dependent code paths.

adam12 commented 3 months ago

It looks like I accidentally dropped the workflow tests for older versions of Rack, which is how this slipped through.

I was going to ask if you wanted a PR for this since I saw a separate gemfile specific for testing this Rack version.

Thanks for the quick fix. I've closed my PR in favour of protocol-rack fix.

ioquatix commented 3 months ago

Thanks for proposing a fix, I really appreciate it!

ioquatix commented 3 months ago

Okay, I just released v0.45.0 which should fix this.