-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for CancellableContinuation #4091
Comments
Interestingly, for me, this test crashes on the JVM as well. |
It also crashes for me on the JVM. On Android, it's either timing (so The cause is straightforward -- there are active coroutines running on the executor that is concurrently closed. So I won't triage it as a bug. We can document it better and maybe (but it's really debatable topic) treat it not as an internal error, but instead raise global exception handler immediately (which, on Android, will crash the app) |
The error message clearly states that any such error is worth reporting to us:
So, I don't think we can ignore it when people do just that. Also, I think this actually is an issue on our side: since there is no guarantee that |
True, we have to acknowledge that.
The documentation (somewhat vaguely, though) states the following:
We can re-visit the corresponding places again, though there are not that many alternatives -- internal error or immediate crash ( |
So what's correct way to close the dispatcher? My real use case is simple: I'm implementing a client which setup websocket connection to backend and creates When an event is received from the websocket - the client parses it on Also the client has So my code looks like:
Is there a better approach than just maintain collection of Like:
|
May I suggest not using |
Correct me if I'm wrong, but I don't see in documentation that
Correct? Which is exactly what I'm trying to avoid by using |
It doesn't guarantee that this will always run on the same thread, so if you have things like thread local variables, yes, |
Thank you, that make sense. Two more questions regarding
|
|
Thank you so much! I'll try to go with Regarding initial issue - I would expect the same behaviour on all platforms. So one of possible solution is to make the test crash on Android the same way how it crashes on iOS and JVM. In this case common code debugged once on android - will work on other platforms without changes. |
@rusmonster, could you please explain why you thought that |
Describe the bug
The following test works on Android, but crashes on iOS:
Output form Android Emulator Arm64 (no crashes, everything works as expected):
Output from iOS Simulator Arm64 (test crashed):
Maybe the root cause is related to fact that on iOS
IllegalStateException
is thrown when flow returns from thewithContext(Dispatchers.Default)
section, in case of android the output above demonstrates that theCancellationException
is thrown at the same place.Versions
The text was updated successfully, but these errors were encountered: