watir-rails icon indicating copy to clipboard operation
watir-rails copied to clipboard

Booting Rails server times out

Open amiel opened this issue 1 year ago • 0 comments

Hi, I'm trying to use watir-rails with Rails 7.0.6, watir 7.2.2, watir-rails 2.3.0, and watir-rspec 5.0.0.

I was getting this error every time:

Rails Rack application timed out during boot

I did some troubleshooting and found that the application was booting, but the __identify__ middleware was returning a different object_id for @app.object_id. It was not getting called twice, so I'm guessing this is a thread-safety issue. I'm not entirely sure why, but while debugging I found that the problem went away if @app.object_id was accessed after creating the app. My initial changes were printing the object id, but the following change caused it to all work again.

I apologize for the issue without a full reproduction, but I thought I would report this in case anyone else is running in to it.

This is the change that works for me:

--- a/lib/watir/rails.rb
+++ b/lib/watir/rails.rb
@@ -112,6 +112,11 @@ module Watir
             run ::Rails.application
           end
         end.to_app
+
+        # Somehow this fixes everything?
+        @app.object_id
+
+        @app
       end
 
       private

amiel avatar Jul 05 '23 23:07 amiel