Skip to content

requestWithStats will have data race in some edge cases #15

Description

@mkungla

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions