Skip to content

Commit

Permalink
GODRIVER-3163 Preserve original cancellation/timeout errors. (mongodb…
Browse files Browse the repository at this point in the history
…#1625)

(cherry picked from commit 091ec6c)
  • Loading branch information
FGasper authored and blink1073 committed May 2, 2024
1 parent c481fdf commit 112f64e
Showing 1 changed file with 2 additions and 2 deletions.
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

0 comments on commit 112f64e

Please sign in to comment.