Skip to content

Conversation

wchargin
Copy link

If a client opens a stream and then cancels it, the server may have already sent response frames back. The HTTP/2 spec says that the client MUST be prepared to receive any such frames. We already handle this correctly for data frames, but prior to this patch, header frames on a canceled stream would cause the whole connection to be torn down. This patch fixes that.

Fixes #1799.

Test Plan:
Unit tests included. Before this change, the new test would fail with "Connection is being forcefully terminated. (errorCode: 1)".

wchargin-branch: http2-headers-after-cancel


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR:
    • Changelog updated
    • Pubspec version revved
    • Tests included

wchargin added 2 commits July 26, 2025 12:03
If a client opens a stream and then cancels it, the server may have
already sent response frames back. The HTTP/2 spec says that the client
MUST be prepared to receive any such frames. We already handle this
correctly for data frames, but prior to this patch, header frames on a
canceled stream would cause the whole connection to be torn down.
This patch fixes that.

Fixes dart-lang#1799.

Test Plan:
Unit tests included. Before this change, the new test would fail with
"Connection is being forcefully terminated. (errorCode: 1)".

wchargin-branch: http2-headers-after-cancel
wchargin-source: 428af2c7cf2fc9f18884558e2b471d2d29a05998
wchargin-branch: http2-headers-after-cancel
wchargin-source: 8aed54b8d5bcc0450db8f46ab08a8012f4de1bd8
@wchargin
Copy link
Author

Hello! This is my first time writing Dart code. I tried to follow local style, and ran dart format, dart fix, and dart analyze. Please let me know if you'd like any modifications; happy to conform to your preferences.

@wchargin
Copy link
Author

Hi @brianquinlan, might you be able to please take a look at this PR? I saw that you have a goal of a weekly PR review cadence and I look forward to any feedback you might have. We're currently working around this bug in our servers, and it would be great to get a fix upstreamed.

@brianquinlan brianquinlan requested a review from mosuem August 18, 2025 17:14
Copy link

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
http2 Non-Breaking 2.3.1 3.0.1-wip 2.4.0 ✔️
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ✔️
File Coverage
pkgs/http2/lib/src/streams/stream_handler.dart 💚 91 % ⬆️ 1 %

This check for test coverage is informational (issues shown here will not fail the PR).

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
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

@brianquinlan
Copy link
Collaborator

@mosuem Could you take a look at this?

@mosuem
Copy link
Member

mosuem commented Aug 21, 2025

Will do, thanks for the ping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After client's RST_STREAM, headers from the server cause client to tear down connection
3 participants