-
Notifications
You must be signed in to change notification settings - Fork 227
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
req.Body
not reset in doWithRetry
#773
Comments
nice! Want to make a PR? |
Sure, I just need to dig a little deeper as there might be another anomaly in the way requests are handled. Not sure I get the full picture yet. |
Update: I can reproduce the issue with func(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
} func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
} The second handler does not always show the I was also able to catch it once using the func receive(ctx context.Context, event cloudevents.Event) error {
fmt.Printf("got event: %v\n", event)
return http.NewResult(nethttp.StatusInternalServerError, nethttp.StatusText(nethttp.StatusInternalServerError))
} Still not sure where and how it gets triggered in all these (rare) scenarios, but perhaps there's a race which only shows during debugging - typical Heisenbug :D Also, I was wondering why the unit tests were not exhibiting the problem: this is caused by only using a |
Closes: cloudevents#773 Signed-off-by: Michael Gasch <[email protected]>
Closes: cloudevents#773 Signed-off-by: Michael Gasch <[email protected]>
Closes: #773 Signed-off-by: Michael Gasch <[email protected]>
Closes: #773 Signed-off-by: Michael Gasch <[email protected]> Co-authored-by: Michael Gasch <[email protected]>
Scenario:
When using a
net/http
HTTP server as remote/receiver (instead of the receiver from this package),ceClient
has issues when retrying a non-successful HTTP response.Error:
"msg":"Invalid result type, not HTTP Result: Post \"http://always-fail.default.127.0.0.1.sslip.io\": http: ContentLength=34 with Body length 0 (type: *protocol.Receipt)"}
This happens when the remote server returns a message in the response, e.g. „server down“ (not CE) but not when just returning a status code and empty response body.
The issue is caused by
func (p *Protocol) doWithRetry()
because it does not reset thereq.Body
during subsequent attempts.Expected behavior:
Return encoding error, but correctly reset
req.Body
, e.g. return"failed to convert response into event: unknown Message encoding\n500: (3x)"
Client code:
HTTP server code (note: just using
net/http
)Patch
The text was updated successfully, but these errors were encountered: