Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Set timeout before registering cancellation token callback
  • Loading branch information
vonzshik committed Dec 18, 2024
commit 45448d5689568fe6035cbf9348d4d42d58312083
6 changes: 3 additions & 3 deletions src/Npgsql/Internal/NpgsqlConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2482,13 +2482,13 @@ UserAction DoStartUserAction(ConnectorState newState, NpgsqlCommand? command,
State = newState;
_currentCommand = command;

StartCancellableOperation(cancellationToken, attemptPgCancellation);

// We reset the ReadBuffer.Timeout for every user action, so it wouldn't leak from the previous query or action
// For example, we might have successfully cancelled the previous query (so the connection is not broken)
// But the next time, we call the Prepare, which doesn't set it's own timeout
// But the next time, we call the Prepare, which doesn't set its own timeout
ReadBuffer.Timeout = TimeSpan.FromSeconds(command?.CommandTimeout ?? Settings.CommandTimeout);

StartCancellableOperation(cancellationToken, attemptPgCancellation);

return new UserAction(this);
}

Expand Down