Skip to content

Commit 1c1a150

Browse files
committed
Rebase
1 parent 180b865 commit 1c1a150

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/MongoDB.Driver/OperationContext.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ public OperationContext Fork() =>
117117
RootContext = RootContext
118118
};
119119

120-
public bool IsTimedOut() => RemainingTimeout == TimeSpan.Zero;
120+
public bool IsTimedOut()
121+
{
122+
// Dotnet APIs like task.WaitAsync truncating the timeout to milliseconds.
123+
// We should truncate the remaining timeout to the milliseconds, in order to maintain the consistent state:
124+
// if operationContext.WaitTaskAsync() failed with TimeoutException, we want IsTimedOut() returns true.
125+
return (int)RemainingTimeout.TotalMilliseconds == 0;
126+
}
121127

122128
public bool IsCancelledOrTimedOut() => IsTimedOut() || CancellationToken.IsCancellationRequested;
123129

0 commit comments

Comments
 (0)