lit icon indicating copy to clipboard operation
lit copied to clipboard

coro-http has no timeout

Open edubart opened this issue 8 years ago • 2 comments

Coro http has no timeout option, if you do a HTTP request to an unresponsive address the coroutine it will never resume.

Test case:

local http = require 'coro-http'
coroutine.wrap(function()
  http.request('GET', 'http://123.123.123.123/')
end)()

Running this example with luvit it will run forever.

This is problematic because I was running a daemon using coro-http and it got stuck forever when my network was down, even after the network became alive again.

edubart avatar Jun 15 '17 13:06 edubart

I hit the same problem and I made some changes to my copy of the the core coro-wrapper and coro-channel libraries to provide support for optional read timeouts. They would need to be wired through to http library, but shouldn't be too difficult. Just look for :read in there.

halfnelson avatar Aug 02 '17 12:08 halfnelson

@halfnelson would you like to send a PR to see if your changes can get merged here?

creationix avatar Aug 02 '17 18:08 creationix