cardano-community/koios-go-client

requestWithStats will have data race in some edge cases

mkungla opened this issue · 0 comments

Describe the bug

Some edge cases when request context is canceled while request with httptrace.WithClientTrace is busy can cause data race,

func (c *Client) requestWithStats(req *http.Request, res *Response) (*http.Response, error) {

https://pkg.go.dev/net/http/httptrace#ContextClientTrace

ClientTrace is a set of hooks to run at various stages of an outgoing HTTP request. Any particular hook may be nil. Functions may be called concurrently from different goroutines and some may be called after the request has completed or failed.

To Reproduce
Steps to reproduce the behavior:

  1. When context is canceled nanoseconds after rate limiter allows next request