feat: Support Logical Termination on RunQueryResponse#1741
Merged
cherylEnkidu merged 3 commits intomainfrom Jun 30, 2022
Merged
feat: Support Logical Termination on RunQueryResponse#1741cherylEnkidu merged 3 commits intomainfrom
cherylEnkidu merged 3 commits intomainfrom
Conversation
dev/src/reference.ts
Outdated
| }) | ||
| .on('end', () => { | ||
| if (hasResolve) return; | ||
| hasResolve = true; |
Contributor
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
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
wu-hui
approved these changes
Jun 28, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Logical Termination: RunQueryResponse will emit "end" event when the "data" event proto which has "done" field set to true.