Skip to content
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

Spawning an isolate with an unserializable message throws an uncatchable exception #14718

Closed
nex3 opened this issue Nov 1, 2013 · 3 comments
Closed
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate

Comments

@nex3
Copy link
Member

nex3 commented Nov 1, 2013

Consider the following code:

    Isolate.spawn(print, () {}).catchError((e) => print("caught $e"));

This throws an uncatchable exception. The exception should be surfaced through the returned future so it can be handled properly.

@lrhn
Copy link
Member

lrhn commented Nov 15, 2013

The error is not uncatchable. It is directly thrown by Isolate.spawn, which is arguably reasonable for an Error (in this case ArgumentError) - it represents a programming error, which should not happen in a correct program.

It is a problem, though, that there is no way to check whether an object is serializable short of attempting to serialize it, so the Error should perhaps be a non-Error exception instead. In that case, it would make more sense to put it into the future.

More interesting is it that the program hangs after catching the error:

import"dart:isolate";

main() {
 try {
   Isolate.spawn(print, () {}).catchError((e) => print("caught $e"));
 } catch (e) {
   print("catch $e");
 }
 print("Done");
}

This program prints "catch ..." and "Done" and then fails to terminate.

@nex3
Copy link
Member Author

nex3 commented Nov 15, 2013

It's very confusing when an asynchronous method synchronously throws errors.

@lrhn
Copy link
Member

lrhn commented Mar 19, 2015

Seems the error now goes into the future returned by Isolate.spawn.


Added Fixed label.

@nex3 nex3 added Type-Defect library-isolate area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Mar 19, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate
Projects
None yet
Development

No branches or pull requests

3 participants