Skip to content

Commit 5007a03

Browse files
committed
fix: serverless, add return-await rule
1 parent ad36aa3 commit 5007a03

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

.eslintrc.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@
201201
],
202202
"parser": "@typescript-eslint/parser",
203203
"parserOptions": {
204-
"project": ["./tsconfig.json"]
204+
"project": [
205+
"./tsconfig.json"
206+
]
205207
},
206208
"extends": [
207209
"plugin:@typescript-eslint/recommended-requiring-type-checking"
@@ -212,9 +214,13 @@
212214
"@typescript-eslint/no-unsafe-assignment": "off",
213215
"@typescript-eslint/no-unsafe-return": "off",
214216
"@typescript-eslint/no-unsafe-call": "off",
215-
216217
"@typescript-eslint/restrict-plus-operands": "off",
217-
"@typescript-eslint/restrict-template-expressions": "off"
218+
"@typescript-eslint/restrict-template-expressions": "off",
219+
"no-return-await": "off",
220+
"@typescript-eslint/return-await": [
221+
"error",
222+
"in-try-catch"
223+
]
218224
}
219225
},
220226
{

src/bulk/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ export abstract class BulkOperationBase {
13051305
const finalOptions = { ...this.s.options, ...options };
13061306
const operation = new BulkWriteShimOperation(this, finalOptions);
13071307

1308-
return await executeOperation(this.s.collection.s.db.s.client, operation);
1308+
return executeOperation(this.s.collection.s.db.s.client, operation);
13091309
}, callback);
13101310
}
13111311

src/mongo_client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> {
590590
return maybeCallback(async () => {
591591
options = typeof options !== 'function' ? options : undefined;
592592
const client = new this(url, options);
593-
return await client.connect();
593+
return client.connect();
594594
}, callback);
595595
}
596596

src/operations/drop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class DropCollectionOperation extends CommandOperation<boolean> {
7272
}
7373
}
7474

75-
return await this.executeWithoutEncryptedFieldsCheck(server, session);
75+
return this.executeWithoutEncryptedFieldsCheck(server, session);
7676
})().then(
7777
result => callback(undefined, result),
7878
err => callback(err)

src/operations/execute_operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,5 +272,5 @@ async function retryOperation<
272272
);
273273
}
274274

275-
return await operation.executeAsync(server, session);
275+
return operation.executeAsync(server, session);
276276
}

test/integration/sessions/sessions.test.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,6 @@ describe('Sessions Spec', function () {
386386
let testCollection;
387387

388388
beforeEach(async function () {
389-
if (this.configuration.isServerless) {
390-
if (this.currentTest) {
391-
this.currentTest.skipReason =
392-
'Serverless actually tests parallel connect which is broken';
393-
}
394-
return this.skip();
395-
}
396389
utilClient = await this.configuration
397390
.newClient({ maxPoolSize: 1, monitorCommands: true })
398391
.connect();
@@ -402,11 +395,12 @@ describe('Sessions Spec', function () {
402395
await utilClient.close();
403396

404397
// Fresh unused client for the test
405-
client = await this.configuration.newClient({ maxPoolSize: 1, monitorCommands: true });
398+
client = await this.configuration.newClient({
399+
maxPoolSize: 1,
400+
monitorCommands: true
401+
});
402+
await client.connect(); // Parallel connect issue
406403
testCollection = client.db('test').collection('too.many.sessions');
407-
408-
utilClient.name = 'ann';
409-
client.name = 'bob';
410404
});
411405

412406
afterEach(async () => {

0 commit comments

Comments
 (0)