-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Isolate errors are not reported, if there is no error listener #26626
Comments
That is surprising. The problem here might be that syntax errors are not normal errors, and they immediately terminate the isolate without going through the normal steps (#23684). Still, the error is reported if you do have an error listener, so it should be printed if you don't. |
The embedder (command line dart) gets back control only from the main isolate when uncaught errors happen. So when the main isolate has such uncaught errors they are printed by the embedder. In this example the error is happening in the spawned isolate and the embedder does not get any control back after the error happens and hence nothing is being reported. I think the error maybe written to the console if --trace-isolates flag is used. |
Ok, so this is expected behavior? |
I can't find any We had another user running into this. When there are no error-listeners we should just report the error on the console. |
|
…nhandled exceptions. Given ``` import 'dart:isolate'; import 'dart:async'; void func(_) { throw new Exception('bad news'); } void main() { ReceivePort receivePort; receivePort = new ReceivePort()..listen((_) { receivePort.close(); throw "more bad news"; } ); Isolate.spawn(func, [], onExit: receivePort.sendPort); } ``` Before this change only 'more bad news' will be printed on the stderr, after this change both 'bad news' and 'more bad news' will be printed out. Before: ``` $ out/ReleaseX64/dart $DH/exc.dart Unhandled exception: more bad news ``` After: ``` $ out/ReleaseX64/dart $DH/exc.dart Isolate is shutting down with the error: Unhandled exception: Exception: bad news Unhandled exception: more bad news ``` Bug: #26626 Change-Id: Ief15f254837d9a02b93a6da655051fccf7c3dd2e Reviewed-on: https://dart-review.googlesource.com/c/52680 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Alexander Aprelev <aam@google.com>
It is essential for any Dart environment to report all uncaught errors.
However, errors that occur inside running
Isolate
are not reported, the isolate is just suspended without any message to console. This is not programmer-friendly and complicates writing simple programs.Consider the following example:
The code contains a mistake,
await
is used in a functionentryPoint
that is not marked asasync
.The programmer would expect to get a message about the mistake. Instead he/she gets "nothing happens" situation and he/she has no clue about what is wrong. To investigate the problem it is necessary to add error listener to the isolate, like this:
Output:
The function
main
here has 2.5 times more lines of code.Dart VM version: 1.16.1 (Tue May 24 12:27:14 2016) on "windows_x64"
The text was updated successfully, but these errors were encountered: