Hi, recently I wondered the question about what would happen if http timeout but the request is still sent out. The motive is, let's assume we make a post request with a timeout. When timeout, the request is canceled, and the server won't serve it anymore. However, if the request is sent out when timeout, the server actually proceeds it anyway, which may make an unexpected error. So I would like to know how to avoid such an error. Do we need to additional check in the application layer, or could we check it inside the http library?
I triggered the timeout by debugger breakpoint in goland, I set the breakpoint at err = pc.bw.Flush() <https://github.com/golang/go/blob/release-branch.go1.19/src/net/http/transport.go#L2408> in writeLoop and n, err = w.pc.conn.Write(p) <https://github.com/golang/go/blob/release-branch.go1.19/src/net/http/transport.go#L1767> . In my opinion, the socket is closed once the timeout happens, and the n, err = w.pc.conn.Write(p) <https://github.com/golang/go/blob/release-branch.go1.19/src/net/http/transport.go#L1767> will always fail as *use of closed network connection*. However, the result is it could send out the bytes, I guess it's caused by the debugger, but have no idea about it. [image: Image Pasted at 2023-1-3 15-09.png] -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d72494ee-690c-4138-a3d1-390a8f0f1276n%40googlegroups.com.