From ea7b50d33af105fc3cca368bcf37c5ca9f84aac1 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Fri, 24 Apr 2020 14:52:26 +0100 Subject: [PATCH] Switch to telling SseHandler to shutdown instead of closing each connection This allows bypassing the keep-alive period and fixes #950. --- dwds/debug_extension/pubspec.yaml | 2 +- dwds/lib/src/handlers/dev_handler.dart | 6 +----- dwds/pubspec.yaml | 2 +- dwds/test/fixtures/fakes.dart | 3 +++ webdev/pubspec.yaml | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/dwds/debug_extension/pubspec.yaml b/dwds/debug_extension/pubspec.yaml index 7336b167a..39dd6235c 100644 --- a/dwds/debug_extension/pubspec.yaml +++ b/dwds/debug_extension/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: js: ^0.6.1+1 pedantic: ^1.5.0 pub_semver: ^1.3.2 - sse: ^3.2.0 + sse: ^3.5.0 dev_dependencies: webdev: ^2.0.0 diff --git a/dwds/lib/src/handlers/dev_handler.dart b/dwds/lib/src/handlers/dev_handler.dart index 27585c6d6..5d5460c35 100644 --- a/dwds/lib/src/handlers/dev_handler.dart +++ b/dwds/lib/src/handlers/dev_handler.dart @@ -91,11 +91,7 @@ class DevHandler { Future close() => _closed ??= () async { await _sub.cancel(); - // We listen for connections to close and remove them from the connections - // set. Therefore we shouldn't asynchronously iterate through the - // connections. - await Future.wait(_injectedConnections - .map((injectedConnection) => injectedConnection.sink.close())); + _sseHandler.shutdown(); await Future.wait(_servicesByAppId.values.map((service) async { await service.close(); })); diff --git a/dwds/pubspec.yaml b/dwds/pubspec.yaml index ea4b7ac55..ab789e4e7 100644 --- a/dwds/pubspec.yaml +++ b/dwds/pubspec.yaml @@ -31,7 +31,7 @@ dependencies: shelf_static: ^0.2.8 shelf_web_socket: ^0.2.0 source_maps: ^0.10.0 - sse: ^3.2.0 + sse: ^3.5.0 vm_service: 4.0.0 web_socket_channel: ^1.0.0 webkit_inspection_protocol: '>=0.5.0+1 <0.6.0' diff --git a/dwds/test/fixtures/fakes.dart b/dwds/test/fixtures/fakes.dart index 262e8c943..b40d02f14 100644 --- a/dwds/test/fixtures/fakes.dart +++ b/dwds/test/fixtures/fakes.dart @@ -122,6 +122,9 @@ class FakeSseConnection implements SseConnection { StreamChannel transformStream( StreamTransformer transformer) => null; + + @override + void shutdown() {} } class FakeWebkitDebugger implements WebkitDebugger { diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml index a79d984c3..0d37720f5 100644 --- a/webdev/pubspec.yaml +++ b/webdev/pubspec.yaml @@ -28,7 +28,7 @@ dependencies: shelf: ^0.7.4 shelf_proxy: ^0.1.0+5 shelf_static: ^0.2.8 - sse: ^3.2.0 + sse: ^3.5.0 vm_service: '>=3.0.0 <5.0.0' webkit_inspection_protocol: '>=0.4.0 <0.6.0' yaml: ^2.1.13