Skip to content

Commit 73a3587

Browse files
fix CI
1 parent fed9604 commit 73a3587

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,12 @@ export type {
540540
export type { InsertManyResult, InsertOneOptions, InsertOneResult } from './operations/insert';
541541
export type { CollectionInfo, ListCollectionsOptions } from './operations/list_collections';
542542
export type { ListDatabasesOptions, ListDatabasesResult } from './operations/list_databases';
543-
export type { AbstractOperation, Hint, OperationOptions } from './operations/operation';
543+
export type {
544+
AbstractOperation,
545+
Hint,
546+
OperationOptions,
547+
RetryContext
548+
} from './operations/operation';
544549
export type { ProfilingLevelOptions } from './operations/profiling_level';
545550
export type { RemoveUserOptions } from './operations/remove_user';
546551
export type { RenameOptions } from './operations/rename';

src/operations/execute_operation.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,10 @@ async function executeOperationWithRetries<
254254
2 // backoff rate
255255
);
256256

257-
const retryContext = new RetryContext(willRetry, timeoutContext.csotEnabled() ? Infinity : 2);
257+
const retryContext = new RetryContext(
258+
willRetry,
259+
willRetry ? (timeoutContext.csotEnabled() ? Infinity : 2) : 1
260+
);
258261

259262
for (; retryContext.shouldRetry(); retryContext.recordFailure(previousOperationError)) {
260263
if (previousOperationError) {
@@ -266,14 +269,18 @@ async function executeOperationWithRetries<
266269
});
267270
}
268271

272+
// TODO: think about whether or not willRetry checks are necessary here.
269273
const isRetryable =
270274
// bulk write commands are retryable if all operations in the batch are retryable
271-
(operation.hasAspect(Aspect.COMMAND_BATCHING) && operation.canRetryWrite) ||
275+
(willRetryWrite &&
276+
operation.hasAspect(Aspect.COMMAND_BATCHING) &&
277+
operation.canRetryWrite) ||
272278
// if we have a retryable read or write operation, we can retry
273279
(hasWriteAspect && willRetryWrite && isRetryableWriteError(previousOperationError)) ||
274280
(hasReadAspect && willRetryRead && isRetryableReadError(previousOperationError)) ||
275281
// if we have a retryable, system overloaded error, we can retry
276-
(previousOperationError.hasErrorLabel(MongoErrorLabel.SystemOverloadedError) &&
282+
(willRetry &&
283+
previousOperationError.hasErrorLabel(MongoErrorLabel.SystemOverloadedError) &&
277284
previousOperationError.hasErrorLabel(MongoErrorLabel.RetryableError));
278285

279286
if (!isRetryable) {

src/operations/operation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { type Connection, type MongoError, MongoErrorLabel } from '..';
1+
import { type Connection, type MongoError } from '..';
22
import { type BSONSerializeOptions, type Document, resolveBSONOptions } from '../bson';
33
import { type MongoDBResponse } from '../cmap/wire_protocol/responses';
4+
import { MongoErrorLabel } from '../error';
45
import { type Abortable } from '../mongo_types';
56
import { ReadPreference, type ReadPreferenceLike } from '../read_preference';
67
import type { Server, ServerCommandOptions } from '../sdam/server';

test/unit/assorted/imports.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function* walk(root) {
1515
}
1616
}
1717

18-
describe('importing mongodb driver', () => {
18+
describe.only('importing mongodb driver', () => {
1919
const sourceFiles = walk(path.resolve(__dirname, '../../../src'));
2020

2121
for (const sourceFile of sourceFiles) {

0 commit comments

Comments
 (0)