dont try to create a new isolate if the hot restart fails (#704)
Part of https://github.com/dart-lang/webdev/issues/697
diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md
index ea6dfad..11c7174 100644
--- a/dwds/CHANGELOG.md
+++ b/dwds/CHANGELOG.md
@@ -1,5 +1,7 @@
## 0.7.1-dev
+- Fix a bug where we would try to create a new isolate even for a failed
+ hot restart. This created a race condition that would lead to a crash.
- Don't attempt to write a vm service request to a closed connection.
- Instead we log a warning with the attempted request message and return.
diff --git a/dwds/web/reloader/manager.dart b/dwds/web/reloader/manager.dart
index b543646..c9b5c31 100644
--- a/dwds/web/reloader/manager.dart
+++ b/dwds/web/reloader/manager.dart
@@ -26,7 +26,7 @@
Future<bool> hotRestart() async {
_beforeRestart();
var result = await _restarter.restart();
- _afterRestart();
+ _afterRestart(result);
return result;
}
@@ -35,7 +35,8 @@
window.location.reload();
}
- void _afterRestart() {
+ void _afterRestart(bool succeeded) {
+ if (!succeeded) return;
// Notify package:dwds that the isolate has been created.
// package:dwds will respond with a [RunRequest].
_client.sink.add(jsonEncode(serializers.serialize(IsolateStart((b) => b