Skip to content

Potential bug: Uncaught TypeError: Failed to execute 'enqueue' on 'ReadableStreamDefaultController' #219

@dirkschumacher

Description

@dirkschumacher

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions