Mark
09/16/2019, 8:33 AM"kotlinx.coroutines.channels.ClosedSendChannelException: Channel was closed"
when calling SendChannel.send
(note: I’m using produce
to build the channel). I’ve isolated the cause to be this upgrade. I couldn’t find anything relevant in the release notes: https://github.com/Kotlin/kotlinx.coroutines/releases . Any tips on how to investigate what could be causing this, please?octylFractal
09/16/2019, 8:35 AMproduce
look like?louiscad
09/16/2019, 8:35 AMcancel()
instead of close()
.Mark
09/16/2019, 8:42 AMclose()
because I have a reference to the channel (and I think there is no cancel()
on Channel
). Does this mean instead I need to hold onto a reference of the Job
corresponding to the Channel
instead (in order to cancel)?octylFractal
09/16/2019, 8:43 AMcancel
on ChannelReceiveChannel
Mark
09/16/2019, 8:48 AMSendChannel
cancel()
instead of close()
fixed the problem. Is there a reference to this behavior change in the docs somewhere?louiscad
09/16/2019, 8:54 AMclose
function KDoc.octylFractal
09/16/2019, 8:55 AMclose
is for the sending side, indicating it is done sending, cancel
is for the receiving side.close
should never be followed by a send
, because the sender declared the channel to be closed (and similar for cancel
& receiver)Mark
09/16/2019, 9:04 AMclose()
from the receiver. I was actually calling it from a class managing the channels (when the channel becomes obsolete due to external conditions). So now I know cancel()
is the correct way 🙏 But yes, a thorough reading of the docs is probably a wise investment of time!Dico
09/16/2019, 9:12 AMMark
09/16/2019, 9:18 AMVsevolod Tolstopyatov [JB]
09/16/2019, 5:37 PM