From 658e47e99c170605f7ab7502c556aae295ed9f46 Mon Sep 17 00:00:00 2001
From: Nate Bosch <nbosch1@gmail.com>
Date: Fri, 31 Jan 2020 17:33:13 -0800
Subject: [PATCH] Avoid unhandled errors in spawnHybridUri (#1162)

Closes #1007
Closes #1008

We already forward errors across the `StreamChannel` so it isn't
particularly useful to also have them printed to the output on the VM
hosting the runner.

We know that `listen` is only ever called in an Isolate that was spawned
from the runner and the `zone` is the root zone. The uncaught error
handler on the root zone will print the error and then kill the isolate,
we jump straight to killing the isolate instead. This Isolate is only
ever spawned without an `onError` handler that would override the
default.
---
 pkgs/test_core/CHANGELOG.md                        | 1 +
 pkgs/test_core/lib/src/runner/hybrid_listener.dart | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md
index bfc510c6..c3ff65ba 100644
--- a/pkgs/test_core/CHANGELOG.md
+++ b/pkgs/test_core/CHANGELOG.md
@@ -17,6 +17,7 @@
   * Previously the loading pool was 2x larger than the actual concurrency
     setting which could cause flaky tests due to tests being loaded while
     other tests were running, even with `-j1`.
+* Avoid printing uncaught errors within `spawnHybridUri`.
 
 ## 0.2.18
 
diff --git a/pkgs/test_core/lib/src/runner/hybrid_listener.dart b/pkgs/test_core/lib/src/runner/hybrid_listener.dart
index 36e8242f..022405b3 100644
--- a/pkgs/test_core/lib/src/runner/hybrid_listener.dart
+++ b/pkgs/test_core/lib/src/runner/hybrid_listener.dart
@@ -74,7 +74,7 @@ void listen(Function Function() getMain, List data) {
   }, onError: (error, stackTrace) async {
     _sendError(channel, error, stackTrace);
     await channel.sink.close();
-    Zone.current.handleUncaughtError(error, stackTrace);
+    Isolate.current.kill();
   });
 }
 
-- 
GitLab