Gracefully handle debug request errors through the extension (#886)
* Gracefully handle failures to initiate debugging through extension
diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md
index a1d1b87..d93c33c 100644
--- a/dwds/CHANGELOG.md
+++ b/dwds/CHANGELOG.md
@@ -4,6 +4,8 @@
to resolve breakpoint locations.
- Remove dependency on `package:build_daemon`.
- Add `FrontendServerAssetReader` for use with Frontend Server builds.
+- 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
instance could crash your development server.
diff --git a/dwds/lib/src/handlers/dev_handler.dart b/dwds/lib/src/handlers/dev_handler.dart
index bba6506..c61e0e1 100644
--- a/dwds/lib/src/handlers/dev_handler.dart
+++ b/dwds/lib/src/handlers/dev_handler.dart
@@ -364,8 +364,11 @@
extensionDebugger.devToolsRequestStream.listen((devToolsRequest) async {
var connection = _appConnectionByAppId[devToolsRequest.appId];
if (connection == null) {
- throw StateError(
+ // TODO(grouma) - Ideally we surface this warning to the extension so
+ // that it can be displayed to the user through an alert.
+ _logWriter(Level.WARNING,
'Not connected to an app with id: ${devToolsRequest.appId}');
+ return;
}
var appId = devToolsRequest.appId;
if (_servicesByAppId[appId] == null) {