Commit 9e9dfc3d authored by Devon Carew's avatar Devon Carew

fix a race condition with isolate notification (#4286)

* fix a race condition with isolate notification

* return a future
parent 2a2bd7b6
......@@ -394,10 +394,10 @@ class _RunAndStayResident {
observatory = await Observatory.connect(result.observatoryPort);
printTrace('Connected to observatory port: ${result.observatoryPort}.');
observatory.populateIsolateInfo();
observatory.onExtensionEvent.listen((Event event) {
printTrace(event.toString());
});
observatory.onIsolateEvent.listen((Event event) {
printTrace(event.toString());
});
......
......@@ -74,6 +74,11 @@ class Observatory {
_getEventController(data['streamId']).add(event);
}
Future<Null> populateIsolateInfo() async {
// Calling this has the side effect of populating the isolate information.
await waitFirstIsolate;
}
Future<IsolateRef> get waitFirstIsolate async {
if (isolates.isNotEmpty)
return isolates.first;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment