-
Notifications
You must be signed in to change notification settings - Fork 540
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
Additional context deadline handling in makeRequestWithAuthTypeAndHeadersComplete #1080
Additional context deadline handling in makeRequestWithAuthTypeAndHeadersComplete #1080
Conversation
…logic and make it clear why the request failed
changelog detected ✅ |
thanks for digging into this one. let's add this in a test with the assertion that we get the correct exception. once we have that, we're good to go. |
Codecov Report
@@ Coverage Diff @@
## master #1080 +/- ##
==========================================
+ Coverage 49.94% 50.07% +0.12%
==========================================
Files 115 117 +2
Lines 10991 11090 +99
==========================================
+ Hits 5490 5553 +63
- Misses 4338 4362 +24
- Partials 1163 1175 +12
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
1) better readability 2) making use of an actual http endpoint 3) ability to run the test individually Increasing timeout values to make sure we get to api.request function and not timing out on rate limiter
So, we actually have a test called "TestContextTimeout" that is checking for error type, the reason it didn't catch v0.48 regression is because when we set context timeout to "0", the deadline gets reached on https://github.com/cloudflare/cloudflare-go/pull/1080/files#diff-432b285f81cb984bfd1ce00fa760be757c96784135a1b9ecd49d3b6c9a26522bR250 , even before we make a request. The error that's currently being returned (before this change) is also of the right type, it's just extra wrapped in "backoff" error. Once the change is merged, it won't be wrapped by the "backoff" error but with retain context.DeadlineExceeded var type. I'm not sure it's worth looking for an unwrapped error in the test but happy to make the change if you have strong opinion on it. I tweaked the test to spin up an actual endpoint to timeout on and increased the timeout value so we can get to api.request block, which makes it more realistic practical scenario. As a bonus, it's easier to understand what the test is doing and which URL it's calling. It also makes it run individually just fine now. |
i think that updated test is great, thank you. |
This functionality has been released in v0.50.0. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Currently, the request retry / backoff logic is being applied to requests that reached context timeout. While it still works as we account for context deadline, it may be better to exit immediately. It also indirectly helps to safeguard from regressions like the ones introduced in v0.48.0 (fixed by #1072) as the response body is nil when go http client exits on context deadline (less processing/potentially less bugs).
Now, the error will just say that we reached the deadline for that specific request and doesn't imply we applied backoff logic or retried the request. It doesn't take away from the ability to surface more specific errors.
Also updating TestContextTimeout to:
Has your change been tested?
Ran a request with short context timeout to reproduce the issue, confirmed it the expected result on timeout is long enough for a request to finish
Screenshots (if appropriate):
Types of changes
What sort of change does your code introduce/modify?
Checklist: