Skip to content

Commit 4ddf71b

Browse files
committed
WIP
1 parent a5c61e2 commit 4ddf71b

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

src/operations/execute_operation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ async function tryOperation<
285285
previousOperationError = operationError;
286286

287287
// Reset timeouts
288-
timeoutContext.serverSelectionTimeout?.clear();
289-
timeoutContext.connectionCheckoutTimeout?.clear();
288+
timeoutContext.clear();
290289
}
291290
}
292291

src/timeout.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ export abstract class TimeoutContext {
174174
abstract csotEnabled(): this is CSOTTimeoutContext;
175175

176176
abstract refresh(): void;
177+
178+
abstract clear(): void;
177179
}
178180

179181
/** @internal */
@@ -280,6 +282,11 @@ export class CSOTTimeoutContext extends TimeoutContext {
280282
this._serverSelectionTimeout?.clear();
281283
this._connectionCheckoutTimeout?.clear();
282284
}
285+
286+
clear(): void {
287+
this._serverSelectionTimeout?.clear();
288+
this._connectionCheckoutTimeout?.clear();
289+
}
283290
}
284291

285292
/** @internal */
@@ -322,4 +329,8 @@ export class LegacyTimeoutContext extends TimeoutContext {
322329
refresh(): void {
323330
return;
324331
}
332+
333+
clear(): void {
334+
return;
335+
}
325336
}

test/integration/client-side-operations-timeout/client_side_operations_timeout.prose.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ describe('CSOT spec prose tests', function () {
217217
});
218218
});
219219

220-
context.skip('5. Blocking Iteration Methods', () => {
220+
context('5. Blocking Iteration Methods', () => {
221221
/**
222222
* Tests in this section MUST only be run against server versions 4.4 and higher and only apply to drivers that have a
223223
* blocking method for cursor iteration that executes `getMore` commands in a loop until a document is available or an
@@ -229,7 +229,7 @@ describe('CSOT spec prose tests', function () {
229229
data: {
230230
failCommands: ['getMore'],
231231
blockConnection: true,
232-
blockTimeMS: 15
232+
blockTimeMS: 20
233233
}
234234
};
235235
let internalClient: MongoClient;
@@ -240,10 +240,11 @@ describe('CSOT spec prose tests', function () {
240240
beforeEach(async function () {
241241
internalClient = this.configuration.newClient();
242242
await internalClient.db('db').dropCollection('coll');
243+
await internalClient.db('db').createCollection('coll', { capped: true, size: 1_000_000 });
243244
await internalClient.db('db').collection('coll').insertOne({ x: 1 });
244245
await internalClient.db().admin().command(failpoint);
245246

246-
client = this.configuration.newClient(undefined, { timeoutMS: 20 });
247+
client = this.configuration.newClient(undefined, { timeoutMS: 20, monitorCommands: true });
247248
commandStarted = [];
248249
commandSucceeded = [];
249250

@@ -287,12 +288,16 @@ describe('CSOT spec prose tests', function () {
287288
*/
288289

289290
it('send correct number of finds and getMores', async function () {
290-
const cursor = client.db('db').collection('coll').find({}, { tailable: true });
291+
const cursor = client
292+
.db('db')
293+
.collection('coll')
294+
.find({}, { tailable: true })
295+
.project({ _id: 0 });
291296
const doc = await cursor.next();
292297
// FIXME: Account for object id
293298
expect(doc).to.deep.equal({ x: 1 });
294299
// Check that there are no getMores sent
295-
expect(commandStarted.filter(e => Object.hasOwn(e.command, 'getMore'))).to.have.lengthOf(0);
300+
expect(commandStarted.filter(e => e.command.getMore != null)).to.have.lengthOf(0);
296301

297302
const maybeError = await cursor.next().then(
298303
() => null,
@@ -301,9 +306,7 @@ describe('CSOT spec prose tests', function () {
301306

302307
expect(maybeError).to.be.instanceof(MongoOperationTimeoutError);
303308
expect(
304-
commandStarted.filter(
305-
e => Object.hasOwn(e.command, 'find') || Object.hasOwn(e.command, 'getMore')
306-
)
309+
commandStarted.filter(e => e.command.find != null || e.command.getMore != null)
307310
).to.have.lengthOf(3);
308311
});
309312
});

test/unit/cursor/aggregation_cursor.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,8 @@ describe('class AggregationCursor', () => {
197197

198198
describe('constructor()', () => {
199199
context('when CSOT is enabled', () => {
200-
let client: MongoClient;
201-
before(function () {
202-
client = new MongoClient('mongodb://iLoveJavascript', { timeoutMS: 100 });
203-
});
204200
context('when timeoutMode=ITERATION and a $out stage is provided', function () {
201+
const client = new MongoClient('mongodb://iLoveJavascript', { timeoutMS: 100 });
205202
expect(() => {
206203
client
207204
.db('test')
@@ -210,6 +207,7 @@ describe('class AggregationCursor', () => {
210207
}).to.throw(MongoAPIError);
211208
});
212209
context('when timeoutMode=ITERATION and a $merge stage is provided', function () {
210+
const client = new MongoClient('mongodb://iLoveJavascript', { timeoutMS: 100 });
213211
expect(() => {
214212
client
215213
.db('test')

0 commit comments

Comments
 (0)