http: port Go net/http timeout handling#67
Conversation
This ports Go's timeout feature to TinyGo allowing it to handle timeouts when using `net/http` e.g. `c := http.Client{Timeout: 2 * time.Second}` will now return a timeout error if the request duration is longer than 2 seconds
By bringing the Go net/http client `.transport()` function, it also fixes the issue where only `roundTrip.go` was used, even when compiling to wasm, where `roundTrip_js.go` should be used
Fixes tinygo-org#58 and tinygo-org#66
146f177 to
ba49238
Compare
Yes, please do so and maybe change |
|
Tested this against a real workload — the Skycoin daemon and web wallet, which use Confirmed it fixes the #58 crash: One thing worth flagging for the native path: the
Not a blocker for this PR — fixing the crash is already a clear improvement. Just flagging that making |
This PR ports Go's
net/httptimeout feature to TinyGo allowing it to handle timeouts when usingnet/httpe.g.^ this will now return a timeout error if the request duration is longer than 2 seconds
This port is pretty much 1:1 to Go own timeout implementation, i removed parts that TInyGo doesnt support (they are commented with
// TINYGO)By bringing the Go
net/httpclient.transport()function, it also fixes the issue where onlyroundTrip.gowas used by default, even when compiling to wasm, whereroundTrip_js.goshould be usedFixes #58
Fixes #66
I have wrote a wasm integration test , but i dont know how to go about it because it's inside
test/wasmin the main repo, do i just open a PR in the main repo with it? or you guys suggest something else?