socketry / async-http

MIT License
298 stars 45 forks source link

Make Body::Pipe background tasks transient #61

Closed bruno- closed 3 years ago

bruno- commented 3 years ago

I watched your video on transient tasks and realized we have a potential bug when Body::Pipe class is used standalone (outside Proxy class).

The problem is simple to reproduce and is covered with specs.

require 'async'
require 'async/http/body/pipe'
require 'async/http/body/writable'

# Body::Pipe dependencies, also fixed in this PR
require 'async/io/socket'
require 'async/io/stream'

Async do
  # pipe that is not closed will hang forever
  Async::HTTP::Body::Pipe.new(Async::HTTP::Body::Writable.new)
end

Types of Changes

Testing

ioquatix commented 3 years ago

Thanks, this seems reasonable, I'll check it in more detail later.

ioquatix commented 3 years ago

Thanks for this, I didn't even review it much to know it's probably the right direction. I'm doing a release of all the http related gems so I'll review it and make changes as required in a latter commit.