refactor(microservices): prevent grpc write promise from throwing #13368
+104
−25
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
currently the Observable that wraps ServerStreaming calls to write data out to the gRPC call object can reject which needs to be caught, even though the
call.emit
in the catch handler won't do anything becausecall.end()
happens before that catch block can run, thanks to theunsubscribe
call in the Subscription cleanup functions used insidewriteObservableToGrpc
Issue Number: N/A
What is the new behavior?
This promise should just never reject in the first place. The Promise is just used to signal when writing has completed and the call has ended. The error signal is handled exclusively by emitting
error
on theCall
.Does this PR introduce a breaking change?
Other information
A series of changes recently outlined here #13360 resulted in a bug where streaming server calls that replied with errors, would crash the application with an
unhandledRejection
. This PR also adds a test case in the integration test for asserting that that doesn't happen again.I renamed the integration test from
sum
because it no longer only tests sum-related endpoints, but theMath
grpc service, so it should be called that instead (the other integration files probably should also). I piggybacked off the existingDivide
function to showcase this behavior by providing a request that will result in an error on the streaming response.