[GODRIVER-2952] Update context.Canceled equality comparisons to errors.Is Created: 22/Aug/23 Updated: 05/Dec/23 Resolved: 06/Oct/23 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.0.0, 1.13.1 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Preston Vasquez | Assignee: | Steve Silvester |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
||||||||||||||||
| Description |
|
In the Go Driver, there are various places where we compare context.Canceled to an error using equality (==). It would be more robust to use errors.Is, in case the error we are comparing to is wrapped. Here is a Go Playground example to demonstrate this behavior:
Here is a non-exhaustive list of places where direct comparisons occur: x/mongo/driver/topology/connection.go#L317 x/mongo/driver/topology/connection.go#L871 x/mongo/driver/topology/server.go#521 x/mongo/driver/topology/server.go#621 |
| Comments |
| Comment by Githook User [ 05/Dec/23 ] |
|
Author: {'name': 'Preston Vasquez', 'email': 'prestonvasquez@icloud.com', 'username': 'prestonvasquez'}Message: Co-authored-by: Ramit Mittal <commitemailoframit@protonmail.com> |
| Comment by Githook User [ 06/Oct/23 ] |
|
Author: {'name': 'Ramit Mittal', 'email': 'commitemailoframit@protonmail.com', 'username': 'ramitmittal'}Message: |