Skip to content

Commit c26de79

Browse files
committed
wip
1 parent d5b4d55 commit c26de79

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export {
4545
export { ClientEncryption } from './client-side-encryption/client_encryption';
4646
export { ChangeStreamCursor } from './cursor/change_stream_cursor';
4747
export {
48+
ConnectionPoolClosedError,
4849
MongoAPIError,
4950
MongoAWSError,
5051
MongoAzureError,
@@ -53,6 +54,7 @@ export {
5354
MongoClientBulkWriteCursorError,
5455
MongoClientBulkWriteError,
5556
MongoClientBulkWriteExecutionError,
57+
MongoClientClosedError,
5658
MongoCompatibilityError,
5759
MongoCursorExhaustedError,
5860
MongoCursorInUseError,

src/mongo_client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,9 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> implements
636636
}
637637

638638
/**
639-
* Cleans up client-side resources used by the MongoCLient and . This includes:
639+
* Cleans up client-side resources used by the MongoClient.
640+
*
641+
* This includes:
640642
*
641643
* - Closes all open, unused connections (see note).
642644
* - Ends all in-use sessions with {@link ClientSession#endSession|ClientSession.endSession()}.

test/integration/change-streams/change_stream.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ describe('Change Streams', function () {
6363
await csDb.createCollection('test').catch(() => null);
6464
collection = csDb.collection('test');
6565
changeStream = collection.watch();
66+
changeStream.on('error', () => null);
6667
});
6768

6869
afterEach(async () => {
@@ -702,15 +703,19 @@ describe('Change Streams', function () {
702703

703704
const outStream = new PassThrough({ objectMode: true });
704705

705-
// @ts-expect-error: transform requires a Document return type
706-
changeStream.stream({ transform: JSON.stringify }).pipe(outStream);
706+
const transform = doc => ({ doc: JSON.stringify(doc) });
707+
changeStream
708+
.stream({ transform })
709+
.on('error', () => null)
710+
.pipe(outStream)
711+
.on('error', () => null);
707712

708713
const willBeData = once(outStream, 'data');
709714

710715
await collection.insertMany([{ a: 1 }]);
711716

712717
const [data] = await willBeData;
713-
const parsedEvent = JSON.parse(data);
718+
const parsedEvent = JSON.parse(data.doc);
714719
expect(parsedEvent).to.have.nested.property('fullDocument.a', 1);
715720

716721
outStream.destroy();

test/integration/index_management.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -770,20 +770,19 @@ describe('Indexes', function () {
770770

771771
expect(events).to.be.an('array').with.lengthOf(1);
772772
expect(events[0]).nested.property('command.commitQuorum').to.equal(0);
773-
await collection.drop(err => {
774-
expect(err).to.not.exist;
775-
});
773+
await collection.drop();
776774
}
777775
};
778776
}
779777
it(
780778
'should run command with commitQuorum if specified on db.createIndex',
781-
commitQuorumTest((db, collection) =>
782-
db.createIndex(collection.collectionName, 'a', {
783-
// @ts-expect-error revaluate this?
784-
writeConcern: { w: 'majority' },
785-
commitQuorum: 0
786-
})
779+
commitQuorumTest(
780+
async (db, collection) =>
781+
await db.createIndex(collection.collectionName, 'a', {
782+
// @ts-expect-error revaluate this?
783+
writeConcern: { w: 'majority' },
784+
commitQuorum: 0
785+
})
787786
)
788787
);
789788
it(

test/integration/node-specific/examples/causal_consistency.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ describe('examples(causal-consistency):', function () {
3131
it('supports causal consistency', async function () {
3232
const session = client.startSession({ causalConsistency: true });
3333

34-
collection.insertOne({ darmok: 'jalad' }, { session });
35-
collection.updateOne({ darmok: 'jalad' }, { $set: { darmok: 'tanagra' } }, { session });
34+
await collection.insertOne({ darmok: 'jalad' }, { session });
35+
await collection.updateOne({ darmok: 'jalad' }, { $set: { darmok: 'tanagra' } }, { session });
3636

3737
const results = await collection.find({}, { session }).toArray();
3838

0 commit comments

Comments
 (0)