Skip to content

Commit 507cf1c

Browse files
committed
chore: revert timeout move
1 parent d3415ed commit 507cf1c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/sdam/topology.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,11 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
559559
new ServerSelectionStartedEvent(selector, this.description, options.operationName)
560560
);
561561
}
562+
let timeout;
563+
if (options.timeoutContext) timeout = options.timeoutContext.serverSelectionTimeout;
564+
else {
565+
timeout = Timeout.expires(options.serverSelectionTimeoutMS ?? 0);
566+
}
562567

563568
const isSharded = this.description.type === TopologyType.Sharded;
564569
const session = options.session;
@@ -581,16 +586,10 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
581586
)
582587
);
583588
}
584-
589+
if (options.timeoutContext?.clearServerSelectionTimeout) timeout?.clear();
585590
return transaction.server;
586591
}
587592

588-
let timeout;
589-
if (options.timeoutContext) timeout = options.timeoutContext.serverSelectionTimeout;
590-
else {
591-
timeout = Timeout.expires(options.serverSelectionTimeoutMS ?? 0);
592-
}
593-
594593
const { promise: serverPromise, resolve, reject } = promiseWithResolvers<Server>();
595594

596595
const waitQueueMember: ServerSelectionRequest = {

test/integration/node-specific/abort_signal.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,9 @@ describe('AbortSignal support', () => {
793793
describe('if reauth throws', () => {
794794
beforeEach(() => {
795795
sinon.stub(ConnectionPool.prototype, 'reauthenticate').callsFake(async function () {
796+
const error = new Error('Rejecting reauthenticate for testing');
796797
await sleep(1000);
797-
throw new Error('Rejecting reauthenticate for testing');
798+
throw error;
798799
});
799800
});
800801

0 commit comments

Comments
 (0)