Production.log says status 200, browser says 500?

I have a long running operation (more than a minute) that is running in
a request. The operation completes according to the log and the log says
that it returns http status 200. Sometimes an error message is written
after the 200 log message (included at the end of this message). But the
browser get a status 500 from the Apache server. We’re using Apache with
SCGI on Windows doing this and my guess is that the error lies somewhere
there (it works using Webrick in dev environment).

What should we do to correct this? Is there a setting in Apache or
perhaps in the SCGI to fix this?

/Marcus

Errno::EINVAL (Invalid argument):

d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/cgi_process.rb:161:in
`flush’

d:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.0/lib/action_controller/cgi_process.rb:161:in
out' d:/ruby/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/dispatcher.rb:38:indispatch’

d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service:23:in
`process_request’

d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service:21:in
`synchronize’

d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service:21:in
process_request' d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:291:inread_header’
d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:253:in
handle_client' d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:234:ininitialize’
d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:234:in
new' d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:234:inhandle_client’
d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:188:in
listen' d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:186:ininitialize’
d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:186:in
new' d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:186:inlisten’
d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/lib/scgi.rb:412:in
run' d:/ruby/lib/ruby/gems/1.8/gems/scgi_rails-0.4.3/bin/scgi_service:61 D:/ruby/bin/scgi_service:18:inload’
D:/ruby/bin/scgi_service:18