-
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
JS - 1.4.0-M1 - Channel based Coroutine cancelling when it shouldn't #2318
Comments
|
What happens to |
I found that by removing the I've tried the same solution for my actual code, and I still encounter the issue. |
I was able to work around this in my code by adding mutex locks around send and close of my channel. |
This also happens on the IR compiler. Is this a Kotlin JS issue or a coroutines issue? |
After re-running the reproducer dozens of times, |
I'm using Kotlin 1.4.10 and kotlinx.coroutines 1.4.0-M1. The below code replicates a race condition I'm seeing in a node process where the data sometimes tries to send after the channel is closed. I'm seeing the coroutine cancel and not complete, when it shouldn't.
I'm not able to reproduce this with a small number of parallel calls, but I'm able to regularly reproduce this, with ~20 calls. I've reproduced what I'm seeing on a smaller scale below.
Description of code:
I'm running separate coroutines (non-child coroutines) that all encounter errors where they try to
send
a value through a channel after it's been closed. The send statements themselves are wrapped intry/catch
, and each coroutine is wrapped in anasync/await
with an additional try catch, returning null if there are any errors / exceptions.The root coroutine should always finish, as it's protected from any of the coroutine errors that could happen. At the end of the root coroutine you can see a print out of
Done
that should happen, but when the error happens,Done
isn't printed, and instead the test fails.I end up with a bunch of these exceptions, and my code never completes:
The text was updated successfully, but these errors were encountered: