diff --git a/.github/workflows/cupertino.yml b/.github/workflows/cupertino.yml index 73f070b5fe..e2d92d12d5 100644 --- a/.github/workflows/cupertino.yml +++ b/.github/workflows/cupertino.yml @@ -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" diff --git a/pkgs/web_socket_conformance_tests/lib/src/peer_protocol_errors_server.dart b/pkgs/web_socket_conformance_tests/lib/src/peer_protocol_errors_server.dart index 8760bb9a38..a40fc1fc54 100644 --- a/pkgs/web_socket_conformance_tests/lib/src/peer_protocol_errors_server.dart +++ b/pkgs/web_socket_conformance_tests/lib/src/peer_protocol_errors_server.dart @@ -14,8 +14,9 @@ const _webSocketGuid = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'; /// WebSocket upgrade. void hybridMain(StreamChannel 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); @@ -28,7 +29,14 @@ void hybridMain(StreamChannel 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