Skip to content
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 Peer requests not terminating when the channel closes #52

Merged
merged 3 commits into from Jun 8, 2020

Conversation

jiahaog
Copy link
Contributor

@jiahaog jiahaog commented May 27, 2020

The listen() method of Peer never propagates close events from its manager to the client field. This causes in-flight requests to never terminate as the clean up handler here is never called.

_manager.done.whenComplete(() {
for (var request in _pendingRequests.values) {
request.completer.completeError(
StateError(
'The client closed with pending request "${request.method}".'),
StackTrace.current);
}
_pendingRequests.clear();

@jiahaog jiahaog force-pushed the fix-close branch 2 times, most recently from 2872f62 to fd4bb81 Compare May 27, 2020 06:11
The `listen()` method of `Peer` never propagates close events from its manager to the `client` field. This causes in-flight requests to never terminate as the clean up handler at https://github.com/dart-lang/json_rpc_2/blob/d589e635d8ccb7cda6a804bd571f88abbabab146/lib/src/client.dart#L65-L72 is never called.
@jiahaog
Copy link
Contributor Author

jiahaog commented Jun 2, 2020

@natebosch Can you help to take a look at this please 🙂

lib/src/peer.dart Outdated Show resolved Hide resolved
@natebosch natebosch merged commit a420a21 into dart-lang:master Jun 8, 2020
@jiahaog jiahaog deleted the fix-close branch June 9, 2020 00:12
dart-bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 12, 2020
In dart-lang/json_rpc_2#52 the `Peer` class was
fixed to behave like a `Client` when the connection is closed with
outstanding requests.

`package:dds` was previously relying on having the futures never
complete to send the `serviceDisappeared` code when the client was
closed with outstanding requests. Check also for the `StateError` that
would result from outstanding requests and translate them to
`serviceDisappeared`.

Change-Id: I2d3f186d1d52d34082b7adf5bf962e22df74015b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158220
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants