Troubleshoot and fix issues in grpc-web JS conformance client #831
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.
There were a couple of bugs in the conformance client that:
Makefile
, so we could atleast run all of the test cases that didn't hang. It turns out this was due to two issues:
metadata
field of an error object was undefined. This tickled a bug that produced an uncaught error, that in turn prevented the result promise from ever being resolved.Previously, the unary case always resolved the promise from the "status" event, and the server-stream case would resolve the promise from the "error" or "end" event (whichever occurred first). I've changed them to now be consistent: we resolve the RPC from the "error" or "end" event (in the case of a unary RPC, it treats the result callback as the "error" event if it supplies an error instead of a message). Also, since we're always resolving from an "error" event, which almost always happens before a "status" event, we now pull the trailers from the error object.
This also adds some other logging and safeguards so that we can hopefully more easily detect problems in the future. So if there is ever an uncaught error, we'll log it. And we also forcibly resolve promises after 15s (with an appropriate error message), so that a failure to resolve the promise from the RPC callbacks won't cause the whole thing to hang.
I added lots of temporary instrumentation and logging in the client to learn the ins-and-outs of what was going on. Here's a summary from that instrumentation:
Out of 71 unary RPCs (of which 57 failed):
status
beforeerror
Out of 62 server-stream RPCs (of which 44 failed):
status
beforeerror
I went ahead a pushed a couple of branches with some exploratory code related to my investigation. The instrumentation that produced the above stats is here. And I also experimented with the use of a non-headless browser, so I code poke at the JavaScript console and see what was happening; that code is here.