posit-dev / posit-dev/shinylive
Potential bug: Uncaught TypeError: Failed to execute 'enqueue' on 'ReadableStreamDefaultController'
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 251
- Forks
- 25
- Avg merge
- 19m
- Merged PRs (30d)
- 2
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/messageporthttp.ts around the enqueue and close calls shown in the report, then trace the MessagePort handler and stream lifecycle. Use a long-running, memory-intensive shinylive application to investigate the intermittent failure; done means the stream completes without attempting to enqueue after it has closed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100