File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
test/integration/node-specific Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import { MONGO_CLIENT_EVENTS } from './constants';
2121import { type AbstractCursor } from './cursor/abstract_cursor' ;
2222import { Db , type DbOptions } from './db' ;
2323import type { Encrypter } from './encrypter' ;
24- import { MongoInvalidArgumentError } from './error' ;
24+ import { MongoInvalidArgumentError , MongoRuntimeError } from './error' ;
2525import { MongoClientAuthProviders } from './mongo_client_auth_providers' ;
2626import {
2727 type LogComponentSeveritiesClientOptions ,
@@ -538,6 +538,10 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
538538 * @see docs.mongodb.org/manual/reference/connection-string/
539539 */
540540 async connect ( ) : Promise < this> {
541+ if ( this . closeLock ) {
542+ throw new MongoRuntimeError ( 'Client cannot be connected while close() is in progress.' ) ;
543+ }
544+
541545 if ( this . connectionLock ) {
542546 return await this . connectionLock ;
543547 }
Original file line number Diff line number Diff line change @@ -762,6 +762,7 @@ describe('class MongoClient', function () {
762762
763763 context ( 'concurrent calls' , ( ) => {
764764 let topologyClosedSpy ;
765+
765766 beforeEach ( async function ( ) {
766767 await client . connect ( ) ;
767768 const coll = client . db ( 'db' ) . collection ( 'concurrentCalls' ) ;
@@ -820,6 +821,8 @@ describe('class MongoClient', function () {
820821 await client . close ( ) ;
821822
822823 expect ( client . topology ) . to . be . undefined ;
824+ } ) ;
825+ } ) ;
823826
824827 describe ( 'active cursors' , function ( ) {
825828 let collection : Collection < { _id : number } > ;
You can’t perform that action at this time.
0 commit comments