In a shinylive application that uses r-shinylive I observed the following client error on Chrome (MacOS) when doing a very long running computation that is also quite memory intensive.
Uncaught TypeError: Failed to execute 'enqueue' on 'ReadableStreamDefaultController': Cannot enqueue a chunk into a closed readable stream
at MessagePort.
The code that produced the error is here
...
if (msg.body) {
streamController!.enqueue(filter(msg.body, response!));
}
if (!msg.more_body) {
// All done
streamController!.close();
clientPort.close();
}
...
It seems like it can happen that a streamController gets closed before all remaining messages have been enqueued. I am sure there are multiple ways to address it. I am also happy to contribute a fix of course (e.g. we could stop the event handler in case the streamContoller has been closed - but maybe the root issue is somewhere else). Also sorry for not providing a reproducible example - quite hard to do so, as this error only occasionally appears.