(
message: WriteProtocolMessageType,
options: CommandOptions & Abortable,
responseType?: MongoDBResponseConstructor
)
| 450 | } |
| 451 | |
| 452 | private async *sendWire( |
| 453 | message: WriteProtocolMessageType, |
| 454 | options: CommandOptions & Abortable, |
| 455 | responseType?: MongoDBResponseConstructor |
| 456 | ): AsyncGenerator<MongoDBResponse> { |
| 457 | this.throwIfAborted(); |
| 458 | |
| 459 | const timeout = |
| 460 | options.socketTimeoutMS ?? |
| 461 | options?.timeoutContext?.getSocketTimeoutMS() ?? |
| 462 | this.socketTimeoutMS; |
| 463 | this.socket.setTimeout(timeout); |
| 464 | |
| 465 | try { |
| 466 | await this.writeCommand(message, { |
| 467 | agreedCompressor: this.description.compressor ?? 'none', |
| 468 | zlibCompressionLevel: this.description.zlibCompressionLevel, |
| 469 | timeoutContext: options.timeoutContext, |
| 470 | signal: options.signal |
| 471 | }); |
| 472 | |
| 473 | if (message.moreToCome) { |
| 474 | yield MongoDBResponse.empty; |
| 475 | return; |
| 476 | } |
| 477 | |
| 478 | this.throwIfAborted(); |
| 479 | |
| 480 | if ( |
| 481 | options.timeoutContext?.csotEnabled() && |
| 482 | options.timeoutContext.minRoundTripTime != null && |
| 483 | options.timeoutContext.remainingTimeMS < options.timeoutContext.minRoundTripTime |
| 484 | ) { |
| 485 | throw new MongoOperationTimeoutError( |
| 486 | 'Server roundtrip time is greater than the time remaining' |
| 487 | ); |
| 488 | } |
| 489 | |
| 490 | for await (const response of this.readMany(options)) { |
| 491 | this.socket.setTimeout(0); |
| 492 | const bson = response.parse(); |
| 493 | |
| 494 | const document = (responseType ?? MongoDBResponse).make(bson); |
| 495 | |
| 496 | yield document; |
| 497 | this.throwIfAborted(); |
| 498 | |
| 499 | this.socket.setTimeout(timeout); |
| 500 | } |
| 501 | } finally { |
| 502 | this.socket.setTimeout(0); |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | private async *sendCommand( |
| 507 | ns: MongoDBNamespace, |
no test coverage detected