-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix request context cancel race when reading response
We had a race between request context cancellation and the reading of the corresponding response. In some circumstances the request context was cancelled before the corresponding response body was read, which resulted in a "context canceled" error. To fix this we create a []context.CancelFunc slice in the routines that call into token-util/DoRetries and we pass-in a pointer to this slice. Then within DoRetries we append each created cancel to this slice. When we return from DoRetries we defer a function to call the cancel functions. In this way we guarantee that we read the response before the corresponding request context is cancelled which fixes the race. We pass-in a slice to ensure that we still comply with the httpclient Do "interface". We've adapted the relevant unit-tests, and also incresed the base httpclient timeout to 120s to allow sufficient time for all retries to be executed. Signed-off-by: Eamonn O'Toole <[email protected]>
- Loading branch information
1 parent
51d5120
commit 99ac698
Showing
7 changed files
with
82 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module github.com/hewlettpackard/hpegl-provider-lib | ||
|
||
go 1.21 | ||
|
||
toolchain go1.22.5 | ||
|
||
require ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters