Skip to content

Commit

Permalink
Bump SSE to v3.1.1 and add server KeepAlive (#876)
Browse files Browse the repository at this point in the history
* Bump sse to v3.1.1 and add server keepalive

This allows the server to accept client reconnections and present them transparently to the consuming code (see dart-lang/sse#18).

* Update CHANGELOG.md

* Disconnect any old isolate
  • Loading branch information
DanTup authored Feb 13, 2020
1 parent af4d71c commit 24b2ba1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
to resolve breakpoint locations.
- Remove dependency on `package:build_daemon`.
- Add `FrontendServerAssetReader` for use with Frontend Server builds.
- Depend on latest `package:sse` for handling client reconnects transparently on the server.
- Fix an issue where a failure to initiate debugging through the Dart Debug
Extension would cause your development server to crash.
- Fix an issue where trying to launch DevTools in a non-debug enabled Chrome
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
js: ^0.6.1+1
pedantic: ^1.5.0
pub_semver: ^1.3.2
sse: ^3.0.0
sse: ^3.1.1

dev_dependencies:
webdev: ^2.0.0
Expand Down
7 changes: 6 additions & 1 deletion dwds/lib/src/handlers/dev_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import '../services/debug_service.dart';
/// opening DevTools.
class DevHandler {
StreamSubscription _sub;
final SseHandler _sseHandler = SseHandler(Uri.parse(r'/$sseHandler'));
final SseHandler _sseHandler = SseHandler(Uri.parse(r'/$sseHandler'),
keepAlive: const Duration(seconds: 30));
final _injectedConnections = <SseConnection>{};
final DevTools _devTools;
final AssetReader _assetReader;
Expand Down Expand Up @@ -310,6 +311,10 @@ class DevHandler {
var services = _servicesByAppId[message.appId];
var connection = AppConnection(message, sseConnection);
if (services != null && services.connectedInstanceId == null) {
// Disconnect any old connection (eg. those in the keep-alive waiting state
// when reloading the page).
services.chromeProxyService?.destroyIsolate();

// Reconnect to existing service.
services.connectedInstanceId = message.instanceId;
await services.chromeProxyService.createIsolate(connection);
Expand Down
3 changes: 2 additions & 1 deletion dwds/lib/src/servers/extension_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import 'package:http_multi_server/http_multi_server.dart';
import 'package:shelf/shelf_io.dart';
import 'package:sse/server/sse_handler.dart';

final _sseHandler = SseHandler(Uri.parse('/\$debug'));
final _sseHandler =
SseHandler(Uri.parse('/\$debug'), keepAlive: const Duration(seconds: 30));

/// A backend for the Dart Debug Extension.
///
Expand Down
2 changes: 1 addition & 1 deletion dwds/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies:
shelf_static: ^0.2.8
shelf_web_socket: ^0.2.0
source_maps: ^0.10.0
sse: ^3.0.0
sse: ^3.1.1
vm_service: 1.2.0
web_socket_channel: ^1.0.0
webkit_inspection_protocol: '>=0.4.0 <0.6.0'
Expand Down
2 changes: 1 addition & 1 deletion webdev/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies:
shelf: ^0.7.4
shelf_proxy: ^0.1.0+5
shelf_static: ^0.2.8
sse: ^3.0.0
sse: ^3.1.1
vm_service: ^1.1.0
webkit_inspection_protocol: '>=0.4.0 <0.6.0'
yaml: ^2.1.13
Expand Down

0 comments on commit 24b2ba1

Please sign in to comment.