Fix hot restart race condition (#644)

* Fix hot restart race condition
diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md
index ddff9c0..fc7ed62 100644
--- a/dwds/CHANGELOG.md
+++ b/dwds/CHANGELOG.md
@@ -1,5 +1,7 @@
 ## 0.5.5
 - Properly set the `pauseEvent` on the `Isolate`.
+- Fix a race condition with Hot Restarts where the Isolate was not created in
+  time for pause events.
 
 ## 0.5.4
 
diff --git a/dwds/lib/src/handlers/dev_handler.dart b/dwds/lib/src/handlers/dev_handler.dart
index 0e19ef2..f4a3f33 100644
--- a/dwds/lib/src/handlers/dev_handler.dart
+++ b/dwds/lib/src/handlers/dev_handler.dart
@@ -257,11 +257,10 @@
         await (await loadAppServices(message.appId, message.instanceId))
             ?.chromeProxyService
             ?.createIsolate();
-        // IsolateStart events are the result of Hot Restarts which immediately
-        // resume execution.
-        await (await loadAppServices(message.appId, message.instanceId))
-            ?.chromeProxyService
-            ?.resumeFromStart();
+        // [IsolateStart] events are the result of a Hot Restart.
+        // Run the application after the Isolate has been created.
+        injectedConnection.sink
+            .add(jsonEncode(serializers.serialize(RunRequest())));
       } else if (message is RunResponse) {
         await (await loadAppServices(message.appId, message.instanceId))
             ?.chromeProxyService
diff --git a/dwds/lib/src/injected/client.js b/dwds/lib/src/injected/client.js
index 5f2c419..ceb51c7 100644
--- a/dwds/lib/src/injected/client.js
+++ b/dwds/lib/src/injected/client.js
@@ -26112,7 +26112,6 @@
       t4 = new M.IsolateStartBuilder();
       H.functionTypeCheck(new D.hotRestart_rerunApp_closure0(), {func: 1, ret: -1, args: [M.IsolateStartBuilder]}).call$1(t4);
       t1.add$1(0, H.assertSubtypeOfRuntimeType(C.C_JsonCodec.encode$2$toEncodable(t3.serialize$1(t4.build$0()), null), t2));
-      self.$dartRunMain.call$0();
     },
     $signature: 0
   };
diff --git a/dwds/web/client.dart b/dwds/web/client.dart
index b7b777c..8c409e7 100644
--- a/dwds/web/client.dart
+++ b/dwds/web/client.dart
@@ -169,10 +169,10 @@
       ..instanceId = dartAppInstanceId))));
     callMethod(getProperty(require('dart_sdk'), 'dart'), 'hotRestart', []);
     // Notify webdev that the isolate has been created.
+    // package:dwds will respond with a [RunRequest].
     sseClient.sink.add(jsonEncode(serializers.serialize(IsolateStart((b) => b
       ..appId = dartAppId
       ..instanceId = dartAppInstanceId))));
-    runMain();
   }
 
   if (modulesToLoad.isNotEmpty) {