-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support Logical Termination on RunQueryResponse #1741
Conversation
dev/src/reference.ts
Outdated
@@ -2024,6 +2025,9 @@ export class Query<T = firestore.DocumentData> implements firestore.Query<T> { | |||
} | |||
}) | |||
.on('end', () => { | |||
if (hasResolve) return; | |||
hasResolve = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasResolved
Also, did you check whether you can just invoke resolve() again?
dev/test/query.ts
Outdated
}) | ||
.on('end', () => { | ||
expect(received).to.equal(2); | ||
expect(++counter).to.equal(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should test that you only receive a single 'end' callback. One think you can do is change this to:
let endCounter = 0;
query
.stream()
.on('data', doc => {
expect(doc).to.be.an.instanceOf(DocumentSnapshot);
++receivedCounter;
})
.on('end', () => {
expect(received).to.equal(2);
++endCounter;
setImmediate(() => {
expect(endCounter).to.equal(1);
callback();
});
});
});
});
This way, you ensure that once all test processing is done, there is an additional check that verifies that 'end' is only called once. Your test right now does the same thing, but once you call callback
test is considered done and it won't fail even if any expectations fail after.
5b04be1
to
cd595cf
Compare
Logical Termination: RunQueryResponse will emit "end" event when the "data" event proto which has "done" field set to true.