Skip to content

Commit 97c130c

Browse files
committed
document contextOwner
1 parent e5e443d commit 97c130c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/change_stream.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,12 @@ export class ChangeStream<
616616
static readonly RESUME_TOKEN_CHANGED = RESUME_TOKEN_CHANGED;
617617

618618
private timeoutContext?: TimeoutContext;
619-
private symbol: symbol;
619+
/**
620+
* Note that this property is here to uniquely identify a ChangeStream instance as the owner of
621+
* the {@link CursorTimeoutContext} instance (see {@link ChangeStream._createChangeStreamCursor}) to ensure
622+
* that {@link AbstractCursor.close} does not mutate the timeoutContext.
623+
*/
624+
private contextOwner: symbol;
620625
/**
621626
* @internal
622627
*
@@ -646,7 +651,7 @@ export class ChangeStream<
646651
);
647652
}
648653

649-
this.symbol = Symbol();
654+
this.contextOwner = Symbol();
650655
this.parent = parent;
651656
this.namespace = parent.s.namespace;
652657
if (!this.options.readPreference && parent.readPreference) {
@@ -905,7 +910,7 @@ export class ChangeStream<
905910
{
906911
...options,
907912
timeoutContext: this.timeoutContext
908-
? new CursorTimeoutContext(this.timeoutContext, this.symbol)
913+
? new CursorTimeoutContext(this.timeoutContext, this.contextOwner)
909914
: undefined
910915
}
911916
);

0 commit comments

Comments
 (0)