Skip to content

Fix Connection reset by peer in protocol error tests #1786

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

Merged
merged 16 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cupertino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ on:
- '.github/workflows/cupertino.yml'
- 'pkgs/cupertino_http/**'
- 'pkgs/http_client_conformance_tests/**'
- 'pkgs/web_socket_conformance_tests/**'
pull_request:
paths:
- '.github/workflows/cupertino.yml'
- 'pkgs/cupertino_http/**'
- 'pkgs/http_client_conformance_tests/**'
- 'pkgs/web_socket_conformance_tests/**'
schedule:
- cron: "0 0 * * 0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const _webSocketGuid = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
/// WebSocket upgrade.
void hybridMain(StreamChannel<Object?> channel) async {
late final HttpServer server;
server = (await HttpServer.bind('localhost', 0))
..listen((request) async {
server = await HttpServer.bind('localhost', 0);
runZonedGuarded(() {
server.listen((request) async {
var key = request.headers.value('Sec-WebSocket-Key');
var digest = sha1.convert('$key$_webSocketGuid'.codeUnits);
var accept = base64.encode(digest.bytes);
Expand All @@ -28,7 +29,14 @@ void hybridMain(StreamChannel<Object?> channel) async {
final socket = await request.response.detachSocket();
socket.write('marry had a little lamb whose fleece was white as snow');
});

}, (e, s) {
// dart:io sometimes asynchronously throws a `SocketException` with
// `errorCode` 54.
// See https://github.com/dart-lang/http/pull/1786 for a full traceback.
if (e is! SocketException || e.osError?.errorCode != 54) {
throw e as Exception;
}
});
channel.sink.add(server.port);

await channel
Expand Down
Loading