Closed Lautenschlager-id closed 4 years ago
Does this always happen? Can you provide code to reproduce the issue?
Yes, I saw your PR but unfortunately it does not handle connection.write when it is string.
You can reproduce it with the code provided in #216
local http = require("coro-http")
coroutine.wrap(function()
http.request("GET", "http://123.123.123.123/", nil, nil, 1000) -- Sets the timeout to 1s
end)()
I don't get your error. I get:
C:\Users\Sinister\Desktop>luvit test.lua
Uncaught Error: C:/Users/Sinister/Desktop/deps/coro-http.lua:74: timeout
stack traceback:
[builtin#2]: at 0x7ff7df1e9eb0
[C]: in function 'run'
[string "bundle:/init.lua"]:52: in function <[string "bundle:/init.lua"]:47>
[C]: in function 'xpcall'
[string "bundle:/init.lua"]:47: in function 'fn'
[string "bundle:deps/require.lua"]:310: in function <[string "bundle:deps/require.lua"]:266>
Oh, I see getConnection
uses assert
now :thinking:
When did that happen? I have been using a pretty recent version and git blame says it is there for 4 yearslol
Not sure. I do know that there is a discrepancy between coro-http (which uses assert) and coro-websocket (which returns nil, err).
When you set a timeout value in
coro-http
.request
, it can happen that the returned value forwrite
is a string"timeout"
, and it ends up breaking inwrite(req)
.Now, it returns a
nil
header with body"timeout"
.Refers to
May be helpful for https://github.com/luvit/lit/issues/216