-
Notifications
You must be signed in to change notification settings - Fork 1.7k
When reporting illegal object SendPort.send should print retaining path and hide implementation internal classes #51115
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
Comments
This error likely indicates that you're trying to send a Future returned from a suspended async function to another isolate. |
Possibly also related to #48592. |
//cc @aam |
Can you explain a bit more about why that doesn't work and what should be done instead? |
Future represents a result of asynchronous computation which is happening within a certain isolate. An ability to await for the completion of that computation and get its result from another isolate would bypass message passing and violate isolation. Sending non-constant objects between isolates involve copying them, so even if we could send futures, the receiving isolate would get its own copy of a Future, which will not be completed by the original asynchronous computation and will not get its result. Internally, SuspendState object represents a stack frame for a suspended asynchronous computation. It is not useful to make a copy of SuspendState in another isolate, as it can only be resumed within the original isolate. |
I think there are two parts here:
/cc @aam @mkustermann I think we are definetely overdue to fix this error message. I even thought we might have an issue already tracking this work - but I could not find it. Would it be something you could look at @aam? PS. I also think that there is an interesting question around sending |
Maybe you were looking for #48592? |
Creating an automatic channel between two isolates when sending a stream or future is too-much-magic mainly because it requires an open receive port in one or both directions. These ports are implicit so users have no way to close them, and if they did, no way to know when to close them. If the VM can do something magic under the hood, where a |
Automatically synchronizing Futures/Streams between isolates makes isolates less isolated. Maybe this should be done through a separate new API, only for a new kind of Future/Stream (SharedFuture, SharedStream etc) so it would only happen if user explicitly asked for such synchronization. Also, if we're willing to breach isolation and open more communication channels between isolates, then we should also consider creating collections which are automatically updated when modified from another isolate (SharedList, SharedMap, SharedSet etc). |
…ception. The exception contains retaining path that looks like this: ``` Invalid argument(s): Illegal argument in isolate message: (object extends NativeWrapper - Library:'dart:io' Class: _RandomAccessFileOpsImpl@14069316) <- Library:'dart:io' Class: _RandomAccessFile@14069316 <- Library:'file:///vm/dart/isolates/send_unsupported_objects_test.dart' Class: SomeLog <- Library:'file:///vm/dart/isolates/send_unsupported_objects_test.dart' Class: SomeState <- Class: Context <- Library:'dart:core' Class: _Closure@0150898 ``` BUG=#51115 BUG=#48592 TEST=send_unsupported_objects_test Change-Id: I022e693adccf43a7d2c95e1c7283fd7f210cf1d7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280523 Commit-Queue: Alexander Aprelev <[email protected]> Reviewed-by: Martin Kustermann <[email protected]> Reviewed-by: Ryan Macnak <[email protected]>
See e.g. simolus3/drift#2279 (comment)
I don't know where SuspendState is defined. It's not defined in Drift AFAICT, and I don't see it when I search on api.dart.dev.
So basically, I don't really know what's wrong or where to start with fixing this issue.
The text was updated successfully, but these errors were encountered: