-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Description
Some g3 users use Future.timeout()
in code, e.g.:
import 'dart:async';
main() async {
await bar();
}
Future bar() async {
await (foo().timeout(Duration(seconds: 1)));
}
Future foo() async {
await 0;
throw 'a';
}
Though the --lazy-async-stacks
implemementation looses track of the awaiter of the Future
returned by .timeout()
:
% out/ReleaseX64/dart --lazy-async-stacks --no-causal-async-stacks async.dart
Unhandled exception:
a
#0 foo (file:///.../test.dart:13:3)
<asynchronous suspension>
#1 Future.timeout.<anonymous closure> (dart:async/future_impl.dart)
<asynchronous suspension>
The implementation looks like this (see future_impl.dart
Future<T> timeout(Duration timeLimit, {FutureOr<T> onTimeout()}) {
_Future<T> result = new _Future<T>();
...
this.then((T v) {
if (timer.isActive) {
timer.cancel();
result._completeWithValue(v);
}
...
});
return result;
}
}
We can consider adding special support for unwinding in this case by recognizing the inner closure in timeout()
and knowing that the result
variable will be available in the context.
b/297400933
Metadata
Metadata
Assignees
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.