-
Notifications
You must be signed in to change notification settings - Fork 388
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
base: master
Are you sure you want to change the base?
Fix fetch
response stream cancellation
#1822
Conversation
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. 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
.
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.
Package | Leaked API symbol | Leaking sources |
---|
This check can be disabled by tagging the PR with skip-leaking-check
.
License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files |
---|
no missing headers |
All source files should start with a license header.
Unrelated files missing license headers
Files |
---|
pkgs/http/example/main.dart |
This check can be disabled by tagging the PR with skip-license-check
.
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. |
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
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 |
The
fetch
client turns aReadableStreamDefaultReader
into a DartStream
by 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:_readBody
loop..cancel()
on its subscription.This fixes the issue by rewriting the logic to use a
StreamController
directly.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.