Skip to content
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

GODRIVER-3163 [master] Preserve original cancellation/timeout errors. #1627

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions x/mongo/driver/topology/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func transformNetworkError(ctx context.Context, originalError error, contextDead

// If there was an error and the context was cancelled, we assume it happened due to the cancellation.
if errors.Is(ctx.Err(), context.Canceled) {
return context.Canceled
return ctx.Err()
}

// If there was a timeout error and the context deadline was used, we convert the error into
Expand All @@ -327,7 +327,7 @@ func transformNetworkError(ctx context.Context, originalError error, contextDead
return originalError
}
if netErr, ok := originalError.(net.Error); ok && netErr.Timeout() {
return context.DeadlineExceeded
return fmt.Errorf("%w: %s", context.DeadlineExceeded, originalError.Error())
}

return originalError
Expand Down