Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/http2: canceling request context does not stop RoundTrip #51173

Closed
aep opened this issue Feb 13, 2022 · 3 comments
Closed

x/net/http2: canceling request context does not stop RoundTrip #51173

aep opened this issue Feb 13, 2022 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@aep
Copy link

aep commented Feb 13, 2022

What version of Go are you using (go version)?

go version go1.17.6 linux/amd64

What did you do?

func ohno(h2client *http2.ClientConn)

     pr, pw := io.Pipe()
  
      ctx, cancel := context.WithCancel(context.Background())
      defer cancel()
  
      var completed = false
      go func () {
          time.Sleep(5*time.Second)
          if !completed {
              //FIXME this does nothing
              cancel();
          }   
      }() 
  
      req, err := http.NewRequestWithContext(ctx, "POST", "https://some/url", pr) 
      if err != nil { panic(err) }
  
      rsp, err := h2client.RoundTrip(req)
      if err != nil { panic(err) }

      completed = true
}

What did you expect to see?

cancel() should cancel the request
note that this works fine with a deadline context, which i can't use because i need a long running connection and only timeout the headers.

What did you see instead?

it does not cancel the request. RoundTrip hangs forever.

@davecheney
Copy link
Contributor

Thank you for your bug report. Before we can investigate we need to rule out the data race in your example.

Have you tried running your program under the race detector? See https://blog.golang.org/race-detector .

@davecheney davecheney added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 13, 2022
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants
@davecheney @aep @gopherbot and others