hashicorp / hashicorp/go-retryablehttp

`Client.Do` never returns on browsers (GOOS=js, GOARCH=wasm)

Open
#166 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
298
PR merge metrics
No merged PRs in 30d

Description

```go
package main

import (
"net/http"
"time"

"github.com/hashicorp/go-retryablehttp"
)

func main() {
c := retryablehttp.NewClient()
c.RetryWaitMax = time.Minute
c.RetryMax = 1e9
req, err := retryablehttp.NewRequest(http.MethodGet, "http://google.com", nil)
if err != nil {
panic(err)
}
res, err := c.Do(req)
if err != nil {
panic(err)
}
_ = res
}
```

1. Run the above code on browsers with GOOS=js and GOARCH=wasm (I use my own [`wasmserve`](https://github.com/hajimehoshi/wasmserve) and Chrome to test this)
2. See the log in Chrome's devtool

Retrying never ends like this:

```
2022/05/06 12:37:55 [DEBUG] GET http://google.com
wasm_exec.js:22 2022/05/06 12:37:55 [ERR] GET http://google.com request failed: Get "http://google.com": dial tcp: lookup google.com: Protocol not available
wasm_exec.js:22 2022/05/06 12:37:55 [DEBUG] GET http://google.com: retrying in 1s (1000000000 left)
wasm_exec.js:22 2022/05/06 12:37:56 [ERR] GET http://google.com request failed: Get "http://google.com": dial tcp: lookup google.com: Protocol not available
wasm_exec.js:22 2022/05/06 12:37:56 [DEBUG] GET http://google.com: retrying in 2s (999999999 left)
wasm_exec.js:22 2022/05/06 12:37:58 [ERR] GET http://google.com request failed: Get "http://google.com": dial tcp: lookup google.com: Protocol not available
wasm_exec.js:22 2022/05/06 12:37:58 [DEBUG] GET http://google.com: retrying in 4s (999999998 left)
wasm_exec.js:22 2022/05/06 12:38:02 [ERR] GET http://google.com request failed: Get "http://google.com": dial tcp: lookup google.com: Protocol not available
wasm_exec.js:22 2022/05/06 12:38:02 [DEBUG] GET http://google.com: retrying in 8s (999999997 left)
wasm_exec.js:22 2022/05/06 12:38:11 [ERR] GET http://google.com request failed: Get "http://google.com": dial tcp: lookup google.com: Protocol not available
wasm_exec.js:22 2022/05/06 12:38:11 [DEBUG] GET http://google.com: retrying in 16s (999999996 left)
wasm_exec.js:22 2022/05/06 12:38:29 [ERR] GET http://google.com request failed: Get "http://google.com": dial tcp: lookup google.com: Protocol not available
```

go-retryablehttp version: v0.7.1
Go version: go1.18 darwin/amd64
Chrome version: 101.0.4951.54 (Official Build) (x86_64)

Thanks,

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.