Skip to content

Commit a3e552a

Browse files
committed
ensure that timeoutMS is passed down correctly
1 parent ff2ec44 commit a3e552a

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

src/collection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ export class Collection<TSchema extends Document = Document> {
254254
this.s.collectionHint = normalizeHintField(v);
255255
}
256256

257+
get timeoutMS(): number | undefined {
258+
return this.s.options.timeoutMS;
259+
}
260+
257261
/**
258262
* Inserts a single document into MongoDB. If documents passed in do not contain the **_id** field,
259263
* one will be added to each of the documents missing it by the driver, mutating the document. This behavior

src/db.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ export class Db {
222222
return this.s.namespace.toString();
223223
}
224224

225+
get timeoutMS(): number | undefined {
226+
return this.s.options?.timeoutMS;
227+
}
228+
225229
/**
226230
* Create a new collection on a server with the specified options. Use this to create capped collections.
227231
* More information about command options available at https://www.mongodb.com/docs/manual/reference/command/create/

src/operations/command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export interface OperationParent {
6464
writeConcern?: WriteConcern;
6565
readPreference?: ReadPreference;
6666
bsonOptions?: BSONSerializeOptions;
67+
timeoutMS?: number;
6768
}
6869

6970
/** @internal */

src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ export function resolveOptions<T extends CommandOperationOptions>(
514514
result.readPreference = readPreference;
515515
}
516516

517+
const timeoutMS = options?.timeoutMS;
518+
519+
result.timeoutMS = timeoutMS ?? parent?.timeoutMS;
520+
517521
return result;
518522
}
519523

0 commit comments

Comments
 (0)