Ensure that the end callback is called #657
Merged
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.
This should fix the case where a server stream was closed by some element on the network (Like envoy proxy with a timeout configured) and grpc-web didn't report any even (Neither 'error' or 'end') this fixes for us symptoms similar to #543 (We also see ERR_INCOMPLETE_CHUNKED_ENCODING more rarely like #361 but don't have a good solution yet)
Previously the end callback was called by checking the state at the end of the
READY_STATE_CHANGE
event.The problem with this approach is that there are multiple early exit cases in this function and when they happen the consumer is never informed of the end of the stream.
The new approach is to only dispatch the event when the
COMPLETE
event is received (Except if an error is dispatched) so the last event is always either'error'
or'end'
).I'd like feedback on this last point as I did the 'only error or end' part by feeling but couldn't find any specification of how it's supposed to work, the other choices being to send error + end when an error is detected.