| 236 | } |
| 237 | |
| 238 | get serverSelectionTimeout(): Timeout | null { |
| 239 | // check for undefined |
| 240 | if (typeof this._serverSelectionTimeout !== 'object' || this._serverSelectionTimeout?.cleared) { |
| 241 | const { remainingTimeMS, serverSelectionTimeoutMS } = this; |
| 242 | if (remainingTimeMS <= 0) |
| 243 | return Timeout.reject( |
| 244 | new MongoOperationTimeoutError(`Timed out in server selection after ${this.timeoutMS}ms`) |
| 245 | ); |
| 246 | const usingServerSelectionTimeoutMS = |
| 247 | serverSelectionTimeoutMS !== 0 && |
| 248 | csotMin(remainingTimeMS, serverSelectionTimeoutMS) === serverSelectionTimeoutMS; |
| 249 | if (usingServerSelectionTimeoutMS) { |
| 250 | this._serverSelectionTimeout = Timeout.expires(serverSelectionTimeoutMS); |
| 251 | } else { |
| 252 | if (remainingTimeMS > 0 && Number.isFinite(remainingTimeMS)) { |
| 253 | this._serverSelectionTimeout = Timeout.expires(remainingTimeMS); |
| 254 | } else { |
| 255 | this._serverSelectionTimeout = null; |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return this._serverSelectionTimeout; |
| 261 | } |
| 262 | |
| 263 | get connectionCheckoutTimeout(): Timeout | null { |
| 264 | if ( |