-
Notifications
You must be signed in to change notification settings - Fork 267
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 concurrent modification error in GrpcWebClientChannel.terminate #332
Conversation
…throwing an exception
|
cc @mraleph |
@isaldana you mentioned in #306 (comment) that this might also fix #206 ? |
@mit-mit I think so. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution and sorry for the delay with reviews.
for (XhrTransportStream request in _requests) { | ||
request.terminate(); | ||
while (_requests.isNotEmpty) { | ||
final XhrTransportStream request = _requests.first; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest:
while (_requests.isNotEmpty) {
final requests = List.of(_requests);
_requests.clear();
await Future.wait(requests.map((rq) => rq.terminate()));
}
this would terminate()
all requests in parallel rather then sequentially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mraleph AFAIK, there is no need to wait for the requests to terminate. It was just the nature of the loop since I didn't want to copy the requests list. I made the change to copy the list of requests and call terminate on them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mraleph Please hold on before merging this. I've been running https://github.com/isaldana/grpc-dart for a while and I just realized that I forgot to include isaldana@0d23114 in this PR.
…ate() function will remove them from the original list.
@isaldana is this in a mergable? Could you rebase and add a test. We now have a gRPC-web testing harness you could use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added test and going to merge.
terminate()
to get called on a web client connection
Fixes #331