diff --git a/lib/async_rack_test/resync_app.rb b/lib/async_rack_test/resync_app.rb index ee28b7b..ed462f3 100644 --- a/lib/async_rack_test/resync_app.rb +++ b/lib/async_rack_test/resync_app.rb @@ -16,8 +16,8 @@ def call(env) result = nil env['async.callback'] = method(:write_async_response) EM.run do - response = app.call(env) - if response[0] == -1 + response = catch(:async) { app.call(env) } + if response.nil? || response[0] == -1 EM.add_periodic_timer(0.1) do unless @async_response.nil? result = @async_response