dart-sdk/runtime/observatory
Vyacheslav Egorov 46ac1f653f [vm] Treat Future.then(..., onError:...) as catch all handler
Commit a52f2b9 which reworked awaiter stack unwinding and its
integration with debugger introduced the following regression:
it stopped treating `Future` listeners which had both `onValue`
and `onError` callbacks as catch all exception handlers. Only
listners with `onError` callback (those created with
`Future.onError`) were treated as a catch all handler.

This meant that debugger started to treat exceptions in the
code below as uncaught:

```
Future<void> foo() {
  await 0;
  throw '';
}

await foo().then(..., onError: (e, st) {

});
```

This change fixes this regression by checking if
`FutureListener.state & stateCatchError != 0` instead of
more narrow `FutureListener.state == stateCatchError` which
only detects listeners which only catch errors but do not
handle values. The new predicate matches
`FutureListener.handlesError`.

This relands 38e0046cad
with a fix to ensure that we correctly detect `onError`
callbacks which simply forward to a suspended async
function. We do this by marking FutureListener's that originate
from `await` using a bit in the state.

Fixes https://github.com/dart-lang/sdk/issues/53334

TEST=service/pause_on_unhandled_async_exceptions{_zones,}_test

Fixed: 53334
CoreLibraryReviewExempt: No fundamental changes to _FutureListener implementation, just additional bit to detect that this listener originates from await
Change-Id: I90385fc619cbb52925e075dd5c7b171a31ca4cab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323481
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-31 11:47:54 +00:00
..
bin Replace Uri.scheme == with Uri.isScheme 2022-02-08 21:38:57 +00:00
lib [vm, service] Represent pool immediates as JSON strings instead of numbers to work around JS representation limits. 2023-08-15 17:55:39 +00:00
tests [vm] Treat Future.then(..., onError:...) as catch all handler 2023-08-31 11:47:54 +00:00
tool Change references to "dartfmt" in runtime and tools to "dart format". 2021-10-01 18:16:27 +00:00
web Spelling runtime observatory 2023-01-20 14:29:08 +00:00
.gitignore [observatory] remove unused_imports and some unused variables 2023-02-15 16:49:58 +00:00
analysis_options.yaml Revert "Separate out UNUSED_ELEMENT_PARAMETER from UNUSED_ELEMENT" 2023-07-24 16:25:07 +00:00
BUILD.gn [build] Use relative paths. 2023-03-08 22:10:42 +00:00
HACKING.md
observatory_sources.gni [ Observatory ] Remove footer with dead / irrelevant links 2021-10-11 23:30:24 +00:00
pubspec.yaml [observatory] remove unused_imports and some unused variables 2023-02-15 16:49:58 +00:00
update_sources.py [infra] Migrate scripts to python3 2021-04-15 10:10:20 +00:00