Skip to content

Commit 4d04edc

Browse files
committed
docs(NODE-6223): add documentation about auto-connect and CSOT
1 parent 7cd3efe commit 4d04edc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/mongo_client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,13 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
510510
/**
511511
* Connect to MongoDB using a url
512512
*
513+
* @remarks
514+
* Calling connect is optional as the first operation you preform will call connect if it's needed.
515+
* `timeoutMS` specified at the client-level will bound the time any operation can take before throwing a timeout error.
516+
* However, when the operation being run is automatically connecting your MongoClient the timeoutMS will only be used for the operation portion of task.
517+
* This means the time to setup the MongoClient does not count against timeoutMS.
518+
* If you are using timeoutMS we recommend connecting your client explicitly in advance of any operation to avoid this inconsistent execution time.
519+
*
513520
* @see docs.mongodb.org/manual/reference/connection-string/
514521
*/
515522
async connect(): Promise<this> {
@@ -713,6 +720,13 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
713720
* Connect to MongoDB using a url
714721
*
715722
* @remarks
723+
* Calling connect is optional as the first operation you preform will call connect if it's needed.
724+
* `timeoutMS` specified at the client-level will bound the time any operation can take before throwing a timeout error.
725+
* However, when the operation being run is automatically connecting your MongoClient the timeoutMS will only be used for the operation portion of task.
726+
* This means the time to setup the MongoClient does not count against timeoutMS.
727+
* If you are using timeoutMS we recommend connecting your client explicitly in advance of any operation to avoid this inconsistent execution time.
728+
*
729+
* @remarks
716730
* The programmatically provided options take precedence over the URI options.
717731
*
718732
* @see https://www.mongodb.com/docs/manual/reference/connection-string/

0 commit comments

Comments
 (0)