(
ns: MongoDBNamespace,
command: Document,
options: CommandOptions & Abortable = {},
responseType?: MongoDBResponseConstructor
)
| 623 | ): Promise<Document>; |
| 624 | |
| 625 | public async command( |
| 626 | ns: MongoDBNamespace, |
| 627 | command: Document, |
| 628 | options: CommandOptions & Abortable = {}, |
| 629 | responseType?: MongoDBResponseConstructor |
| 630 | ): Promise<Document> { |
| 631 | this.throwIfAborted(); |
| 632 | options.signal?.throwIfAborted(); |
| 633 | |
| 634 | for await (const document of this.sendCommand(ns, command, options, responseType)) { |
| 635 | if (options.timeoutContext?.csotEnabled()) { |
| 636 | if (MongoDBResponse.is(document)) { |
| 637 | if (document.isMaxTimeExpiredError) { |
| 638 | throw new MongoOperationTimeoutError('Server reported a timeout error', { |
| 639 | cause: new MongoServerError(document.toObject()) |
| 640 | }); |
| 641 | } |
| 642 | } else { |
| 643 | if ( |
| 644 | (Array.isArray(document?.writeErrors) && |
| 645 | document.writeErrors.some( |
| 646 | error => error?.code === MONGODB_ERROR_CODES.MaxTimeMSExpired |
| 647 | )) || |
| 648 | document?.writeConcernError?.code === MONGODB_ERROR_CODES.MaxTimeMSExpired |
| 649 | ) { |
| 650 | throw new MongoOperationTimeoutError('Server reported a timeout error', { |
| 651 | cause: new MongoServerError(document) |
| 652 | }); |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | return document; |
| 658 | } |
| 659 | throw new MongoUnexpectedServerResponseError('Unable to get response from server'); |
| 660 | } |
| 661 | |
| 662 | public exhaustCommand( |
| 663 | ns: MongoDBNamespace, |
no test coverage detected