Skip to content

Commit a91ce39

Browse files
nbbeekenbaileympearson
authored andcommitted
fix(NODE-6066): ClusterTime.signature can be undefined (mongodb#4069)
1 parent 636cc9a commit a91ce39

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/sdam/common.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,16 @@ export function drainTimerQueue(queue: TimerQueue): void {
5555
queue.clear();
5656
}
5757

58-
/** @public */
58+
/**
59+
* @public
60+
* Gossiped in component for the cluster time tracking the state of user databases
61+
* across the cluster. It may optionally include a signature identifying the process that
62+
* generated such a value.
63+
*/
5964
export interface ClusterTime {
6065
clusterTime: Timestamp;
61-
signature: {
66+
/** Used to validate the identity of a request or response's ClusterTime. */
67+
signature?: {
6268
hash: Binary;
6369
keyId: Long;
6470
};

test/types/sessions.test-d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { expectError, expectType } from 'tsd';
1+
import { expectAssignable, expectError, expectType } from 'tsd';
22

3-
import type { ClientSession } from '../mongodb';
3+
import type { Binary, ClientSession, ClusterTime, Long, Timestamp } from '../mongodb';
44
import { MongoClient, ReadConcern, ReadConcernLevel } from '../mongodb';
55

66
// test mapped cursor types
@@ -25,3 +25,9 @@ const unknownFn: () => Promise<unknown> = async () => 2;
2525
expectType<unknown>(await client.withSession(unknownFn));
2626
// Not a promise returning function
2727
expectError(await client.withSession(() => null));
28+
29+
declare const ct: ClusterTime;
30+
expectType<Timestamp>(ct.clusterTime);
31+
expectAssignable<ClusterTime['signature']>(undefined);
32+
expectType<Binary | undefined>(ct.signature?.hash);
33+
expectType<Long | undefined>(ct.signature?.keyId);

0 commit comments

Comments
 (0)