-
Notifications
You must be signed in to change notification settings - Fork 390
Fix fetch response stream cancellation
#1822
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 fetch response stream cancellation
#1822
Conversation
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthLicense Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with
Coverage
|
| File | Coverage |
|---|---|
| pkgs/http/lib/src/browser_client.dart | 💔 Not covered |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check.
Changelog Entry ✔️
| Package | Changed Files |
|---|
Changes to files need to be accounted for in their respective changelogs.
This check can be disabled by tagging the PR with skip-changelog-check.
brianquinlan
left a comment
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.
Very high quality PR! Especially the added conformance test (a few of which seem to be failing).
|
It looks like the remaining failures are all infra or appear to be unrelated to my changes. Let me know if there's anything I should look into. |
Yep, these have nothing to do with your change. |
brianquinlan
left a comment
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.
Hey @simolus3 ,
I just wanted to let you know what I'm still looking at your change. I've included a few nit picky comments but overall its excellent. What I don't like is the increased complexity of this client. But I can't think of a better way of doing this so probably it is fine the way it is. But it might take me a few days to convince myself of that ;-)
d16b9a0 to
2199424
Compare
lrhn
left a comment
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 think it's pretty good. I can simplify it a little, but the underlying idea is the same.
pkgs/http_client_conformance_tests/lib/src/response_body_streamed_test.dart
Outdated
Show resolved
Hide resolved
pkgs/http_client_conformance_tests/lib/src/response_body_streamed_test.dart
Outdated
Show resolved
Hide resolved
|
Alright, I have adopted most of the suggestions shared by @lrhn. I think they make the control flow a lot more obvious 👍 I think the correct behavior (which we also had with the old Despite being a single-use stream, I think using |
pkgs/http_client_conformance_tests/lib/src/response_body_streamed_test.dart
Show resolved
Hide resolved
|
It looks like one test is failing on WASM. |
|
Thanks, I've fixed that test. |
|
It looks like packages |
|
@simolus3 Thanks for sticking with this and for the great work! |
|
The remaining CI failures are unrelated. |
|
Thanks for fixing the test and reviewing this! |
The
fetchclient turns aReadableStreamDefaultReaderinto a DartStreamby repeatedly invokingreader.read()in anasync*function.This generally works well, but a problem with
async*functions is that they can only respect cancellations when yielding. This results in cancellations taking longer than they need to in the following case:_readBodyloop..cancel()on its subscription.This fixes the issue by rewriting the logic to use a
StreamControllerdirectly.Closes #1820.
cc @brianquinlan
Contribution guidelines:
dart format.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.