-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
net/http: Flush in TimeoutHandler for Go1.13 is broken and might need a revert #34439
Comments
Fair enough, maybe we can just make |
@cuonglm, I don't understand why Faking it just makes it impossible to test for the capability at runtime (the method doesn't even return an error). It's also a violation of the interface description: Any exception should be clearly documented, if justified. |
@pam4 I understand, but dont know if removing it break go1 compatibility or not, so better to make it do nothing, so we can prevent side effect. |
I don't think so. The first release to have that method was 1.13 and any existing program relying on it, is certainly not working as intended. The only "side effect" I can imagine is uncovering an already existing bug. |
So if you removed it, then all go1.13 program which rely on the interface will be broken in go1.14. If it does not break go1 compatibility, then we can remove it . Otherwise, I think it's better to make it as a no-op, and document that timeoutWriter.Flush do nothing. |
@pam4 sorry that we didn't catch this newly introduced issue earlier! Perhaps we have some options from both your suggestions: I suspect with the reasoning of being just being released 3 weeks ago, we can negotiate for a walkback as the problem is quite severe. My personal opinion is going for option b) Kindly pinging @andybons @dmitshur @bradfitz @ianlancetaylor to help with reviewing if/how this can be done. |
Thanks for the reply. IMHO saying that solution It's unclear to me who would benefit from option |
@odeke-em, let's not use Soon for this. The Soon label is only for super urgent things, like golang.org or other sites being down. We basically don't use it. I'm fine reverting the Flusher stuff, though. That's easier than making it work properly. |
@gopherbot, please backport to Go 1.13: we should minimize the window during which the erroneous method is present. |
Backport issue(s) opened: #34560 (for 1.13). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/197659 mentions this issue: |
Oh, I had assumed that this bug was very urgent. Thank you for letting me know, Brad about its usage. |
… interface. The TimeoutHandler temporarily supported Flusher interface during development of 1.13 but it's no longer supported. This change corrects its documentation. Fixes golang#35161 Updates golang#34439
Change https://golang.org/cl/203478 mentions this issue: |
Fixes #35161 Updates #34439 Change-Id: I978534cbb8b9fb32c115dba0066cf099c61d8ee9 GitHub-Last-Rev: d605816 GitHub-Pull-Request: #35162 Reviewed-on: https://go-review.googlesource.com/c/go/+/203478 Reviewed-by: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
Currently (1.13) calling
Flush
on aResponseWriter
exposed byTimeoutHandler
has some undesirable effect:200 OK
status, ignoring whatever the caller set before (e.g.w.Header().Set(key, val)
orw.WriteHeader(someOtherCode)
);TimeoutHandler
to respond with503
on timeout as promised, and it produces a"superfluous response.WriteHeader call"
warning;https://play.golang.org/p/HmW2ETipalB
This is happening because
timeoutWriter.Flush
calls the underlyingFlush
, which in turn calls the underlyingWriteHeader
from a clean state: the actual header and partial body are still buffered in the wrapper (intimeoutWriter.h
andtimeoutWriter.wbuf
).I think
TimeoutHandler
supportingFlush
doesn't make any sense because aTimeoutHandler
doesn't know what to do until either the inner handler returns or the timeout is reached, therefore it needs to buffer the whole response until the end.EDIT: #34198 is probably an effect.
The text was updated successfully, but these errors were encountered: