[dart2wasm] Restore caller's zone when returning from await.

Change-Id: Ifd0013eb130ff98bf2127991b685258ced115824
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262480
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
This commit is contained in:
Joshua Litt 2022-10-05 16:37:59 +00:00 committed by Commit Queue
parent 683e2419da
commit 16d06dac06

View file

@ -86,8 +86,13 @@ class _FutureError {
@pragma("wasm:entry-point")
Object? _awaitHelper(Object? operand, WasmExternRef? stack) {
// Save the existing zone in a local, and restore('_leave') upon returning. We
// ensure that the zone will be restored in the event of an exception by
// restoring the original zone before we throw the exception.
_Zone current = Zone._current;
if (operand is! Future) return operand;
Object? result = _futurePromise(stack, operand);
Zone._leave(current);
if (result is _FutureError) {
// TODO(askesc): Combine stack traces
throw result.exception;