Skip to content

Commit

Permalink
fix(NODE-6066): ClusterTime.signature can be undefined (#4069)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken authored Apr 4, 2024
1 parent c604e74 commit ce55ca9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/sdam/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ export function drainTimerQueue(queue: TimerQueue): void {
queue.clear();
}

/** @public */
/**
* @public
* Gossiped in component for the cluster time tracking the state of user databases
* across the cluster. It may optionally include a signature identifying the process that
* generated such a value.
*/
export interface ClusterTime {
clusterTime: Timestamp;
signature: {
/** Used to validate the identity of a request or response's ClusterTime. */
signature?: {
hash: Binary;
keyId: Long;
};
Expand Down
10 changes: 8 additions & 2 deletions test/types/sessions.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expectError, expectType } from 'tsd';
import { expectAssignable, expectError, expectType } from 'tsd';

import type { ClientSession } from '../mongodb';
import type { Binary, ClientSession, ClusterTime, Long, Timestamp } from '../mongodb';
import { MongoClient, ReadConcern, ReadConcernLevel } from '../mongodb';

// test mapped cursor types
Expand All @@ -25,3 +25,9 @@ const unknownFn: () => Promise<unknown> = async () => 2;
expectType<unknown>(await client.withSession(unknownFn));
// Not a promise returning function
expectError(await client.withSession(() => null));

declare const ct: ClusterTime;
expectType<Timestamp>(ct.clusterTime);
expectAssignable<ClusterTime['signature']>(undefined);
expectType<Binary | undefined>(ct.signature?.hash);
expectType<Long | undefined>(ct.signature?.keyId);

0 comments on commit ce55ca9

Please sign in to comment.