postrank-labs/goliath — Issue #97: "double render" using EM::Deferrable
Author: seamusabshere
Created: 2011-10-19 15:38:57+00:00
State: open

When I run this in Goliath, I always get a double resume

[8096:ERROR] 2011-10-19 10:18:57 :: double resume
~/my_app/lib/reports.rb:31:in `resume'
~/my_app/lib/reports.rb:31:in `block in async_report'
~/.rvm/gems/ruby-1.9.2-p290-patched/gems/eventmachine-1.0.0.beta.4/lib/em/deferrable.rb:48:in `call'
~/.rvm/gems/ruby-1.9.2-p290-patched/gems/eventmachine-1.0.0.beta.4/lib/em/deferrable.rb:48:in `callback'
~/my_app/lib/reports.rb:27:in `async_report'

That's from this code

require 'eventmachine'

class Reports
def initialize(app)
@app = app
end

def call(env)
env['my.reports'] = async_report
@app.call env
end

private

def async_report
f = ::Fiber.current

reporter = Reporter.new
reporter.callback do |reports|
f.resume reports
end

return ::Fiber.yield
end

class Reporter
include ::EventMachine::Deferrable

def initialize
self.succeed ['hello', 'world']
end
end
end

I think the problem may be here, but I don't understand how:

# lib/goliath/request.rb
def post_process(results)
begin
status, headers, body = results
return if status && status == Goliath::Connection::AsyncResponse.first

callback do

Thanks!