RUBY-3683 Fix CSOT for with_transaction by comandeo-mongo · Pull Request #2941 · mongodb/mongo-ruby-driver

Pull Request Overview

This PR fixes CSOT (Client-Side Operation Timeout) handling in the with_transaction method by properly supporting zero/infinite timeouts and refactoring deadline calculation logic.

Key Changes:

  • Refactored deadline calculation into a separate calculate_with_transaction_deadline method that handles timeout_ms: 0 as infinite timeout
  • Added deadline_expired? helper method to properly check deadline expiration, treating 0 as never expired
  • Added comprehensive test coverage for CSOT scenarios including zero timeout, positive timeout, and disabled CSOT

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
spec/mongo/session_transaction_spec.rb Adds test coverage for CSOT with with_transaction, including tests for zero timeout (infinite), positive timeout values, and disabled CSOT scenarios
lib/mongo/session.rb Refactors with_transaction to extract deadline calculation logic and properly handle infinite timeouts (when timeout_ms: 0), plus adds helper method for deadline expiration checks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.