-
Notifications
You must be signed in to change notification settings - Fork 269
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
fix: fix headers not completing when call is terminated #728
Conversation
@kevmoo who would be the right person to take a look at this PR? Thanks in advance! |
Please add a regression test and then we can land it. |
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR).
API leaks
|
Package | Leaked API symbols |
---|---|
grpc | Any $1.Duration ServerHandler |
This check can be disabled by tagging the PR with skip-leaking-check
.
Package publish validation ✔️
Package | Version | Status |
---|---|---|
package:grpc | 4.0.1 | ready to publish |
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.
@mraleph However I had to change the previous logic from throwing an error if (!_headers.isCompleted) {
_headers.completeError(GrpcError.unimplemented('Request terminated before headers'));
} To completing with an empty value if (!_headers.isCompleted) {
_headers.complete({});
} The reason about the change was that the error throwing was really distruptive for the current implementations, instead of receving a error only on active listeners (I.e whoever was actively looking at that completer) all the cancelled calls received 3 throws, one for the cancellation, one for the headers not completed and one for the trailers not completed, this meant that all the tests in this project were failing due to the not catched exceptions, and at the same time, anyone cancelling the call had to deal with 3 different throws, I hope this change make sense to you. |
@mraleph saw some failing tests, but those seems unrelated to my changes, any hint about those? |
These keepalive tests can be flaky, but this doesn't look that way. Let me check. |
It looks like that the tearDown somehow is not awaiting the closing before the next setUp is running, maybe they are running in parallel? in line 52 of keep_alive_test.dart, if you use a different port for each serve you will see the tests not failing anymore //before tests setup
int port = 8081;
//Line 52
await server.serve(address: 'localhost', port: port++); Want me to add this? |
Another thing I discovered, if I run only keep alive tests it works out of the box, so probably tests are running in parallel with other tests using the port 8081, another fix is to use the port 8282 on line 52 /Line 52
await server.serve(address: 'localhost', port: 8082); |
Basically those two tests uses port 8081, this is not an issue when run one by one, but running the whole suite with |
Pushed the fix for |
This PR attempt to solve the issue with headers not being correctly completed after a call is closed as pointed out in #727
To fix the issue I have added in the
_terminate()
method a check to complete with errors any completer still going (I found_headers
and_trailers
)