You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is similar to #45616 but behavior is a little different on the VM.
Reproduction case:
import'dart:async';
voidmain() {
runZoned(() {
somethingAsync();
}, zoneSpecification:ZoneSpecification(handleUncaughtError: handleError));
}
voidhandleError(
Zone _, ZoneDelegate __, Zone ___, Object error, StackTrace stackTrace) {
print('I see the error: $error');
throw'extra error';
}
voidsomethingAsync() async {
awaitFuture.delayed(constDuration(seconds:1));
throw'sad';
}
I would expect either the extra error to never surface back to the handleError callback, or for it to show up in an infinite loop.
What happens in practice it that it surfaces more than 1, but less than ∞ times. The number of times varies by Dart release.
In Dart 2.0.0 and 2.1.0 the output shows up 3 times:
I see the error: sad
I see the error: extra error
I see the error: extra error
I see the error: extra error
Unhandled exception:
extra error
Starting in Dart 2.2.0 the output shows up only 2 times:
I see the error: sad
I see the error: extra error
I see the error: extra error
Unhandled exception:
extra error
There is a similar version disparity in the behavior of an implementation without using async.
import'dart:async';
voidmain() {
runZoned(() {
somethingAsync();
}, zoneSpecification:ZoneSpecification(handleUncaughtError: handleError));
}
voidhandleError(
Zone _, ZoneDelegate __, Zone ___, Object error, StackTrace stackTrace) {
print('I see the error: $error');
throw'extra error';
}
voidsomethingAsync() {
Future.delayed(constDuration(seconds:1)).then((_) {
throw'sad';
});
}
Here the output shows up 1 fewer times:
Dart 2.0.0 and 2.1.0:
I see the error: sad
I see the error: extra error
I see the error: extra error
Unhandled exception:
extra error
Dart 2.2.0 and above:
I see the error: sad
I see the error: extra error
Unhandled exception:
extra error
I think that that the non-async version in recent Dart versions has the best behavior. @lrhn - is this specified somewhere? Should we look at adding any tests for behavior of error handlers which throw themselves?
The text was updated successfully, but these errors were encountered:
natebosch
added
the
area-vm
Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
label
Apr 7, 2021
This is similar to #45616 but behavior is a little different on the VM.
Reproduction case:
I would expect either the
extra error
to never surface back to thehandleError
callback, or for it to show up in an infinite loop.What happens in practice it that it surfaces more than 1, but less than ∞ times. The number of times varies by Dart release.
In Dart
2.0.0
and2.1.0
the output shows up 3 times:Starting in Dart
2.2.0
the output shows up only 2 times:There is a similar version disparity in the behavior of an implementation without using
async
.Here the output shows up 1 fewer times:
Dart
2.0.0
and2.1.0
:Dart
2.2.0
and above:I think that that the non-
async
version in recent Dart versions has the best behavior. @lrhn - is this specified somewhere? Should we look at adding any tests for behavior of error handlers which throw themselves?The text was updated successfully, but these errors were encountered: