Skip to content

Commit

Permalink
fix: revert change to abstract cursor async iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
andymina committed Oct 25, 2022
1 parent e5ad264 commit 16deee1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/change_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ export class ChangeStream<
}, callback);
}

// TODO(andymina): ask about never as third template parameter
async *[Symbol.asyncIterator](): AsyncGenerator<TChange, void, never> {
if (this.closed) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/cursor/abstract_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export abstract class AbstractCursor<
return bufferedDocs;
}

[Symbol.asyncIterator](): AsyncIterator<TSchema, void, never> {
[Symbol.asyncIterator](): AsyncIterator<TSchema, void> {
async function* nativeAsyncIterator(this: AbstractCursor<TSchema>) {
if (this.closed) {
return;
Expand Down
8 changes: 3 additions & 5 deletions test/integration/change-streams/change_stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
ReadPreference,
ResumeToken
} from '../../../src';
import { next } from '../../../src/cursor/abstract_cursor';
import { isHello } from '../../../src/utils';
import * as mock from '../../tools/mongodb-mock/index';
import {
Expand Down Expand Up @@ -953,7 +952,6 @@ describe('Change Streams', function () {
'This test only worked because of timing, changeStream.close does not remove the change listener';
});

// TODO(andymina): ask about testing word semantics here
context('iterator api', function () {
describe('#tryNext()', function () {
it('should return null on single iteration of empty cursor', {
Expand Down Expand Up @@ -1092,7 +1090,7 @@ describe('Change Streams', function () {
}
);

it.only(
it(
'can be used with raw iterator API',
{ requires: { topology: '!single' } },
async function () {
Expand All @@ -1112,7 +1110,7 @@ describe('Change Streams', function () {
const { fullDocument } = change.value;
expect(fullDocument.city).to.equal(docs[1].city);
} catch (error) {
expect.fail('Async could not be used with raw iterator API')
expect.fail('Async could not be used with raw iterator API');
}
}
);
Expand Down Expand Up @@ -2405,7 +2403,7 @@ describe('ChangeStream resumability', function () {

await collection.insertOne({ city: 'New York City' });
try {
const change = await changeStreamIterator.next();
await changeStreamIterator.next();
expect.fail(
'Change stream did not throw unresumable error and did not produce any events'
);
Expand Down

0 comments on commit 16deee1

Please sign in to comment.