[dart_runner] Properly handle non-error Isolate exit
Differentiate an Isolate going down from calling exit()
from package:fuchsia from an Isolate going down due
to an error
Needs: https://fuchsia-review.googlesource.com/c/build/+/155166
FL-51 #done
Change-Id: If2e37f6eac1ab19472ab410a72e3961d9aeaf517
diff --git a/dart_microtask_queue.cc b/dart_microtask_queue.cc
index d102de0..5cd8ee6 100644
--- a/dart_microtask_queue.cc
+++ b/dart_microtask_queue.cc
@@ -75,7 +75,14 @@
for (const auto& callback : local) {
if (auto dart_state = callback.dart_state().lock()) {
DartState::Scope dart_scope(dart_state.get());
- Dart_Handle result = DartInvokeVoid(callback.value());
+ Dart_Handle result = Dart_InvokeClosure(callback.value(), 0, nullptr);
+ // If the Dart program has set a return code, then it is intending to shut
+ // down by way of a fatal error, and so there is no need to emit a log
+ // message.
+ if (!dart_state->has_set_return_code() || !Dart_IsError(result) ||
+ !Dart_IsFatalError(result)) {
+ LogIfError(result);
+ }
DartErrorHandleType error = GetErrorHandleType(result);
if (error != kNoError) {
last_error_ = error;