Skip to content

Bug: ReadableStream can be written to after close #27540

@gnoff

Description

@gnoff

As reported in vercel/next.js#56919 it is possible for the ReadableStream controller to be written to after it is already closed. This is because inside an async context a Float method such as ReactDOM.preload() can attempt to flush newly created Resources even after the stream has completed.

React version:

The underlying bug has been in React since Float landed. The expression of the Bug as reported in the Next.js repo was landed in: 701ac2e
The first Canary release to have this new expression was: 18.3.0-canary-f81c0f1ed-20230927

Steps To Reproduce

  1. use react-dom/server.edge
  2. Ensure the environment supports AsyncLocalStorage
  3. Call Float method like ReactDOM.preload(...) after an await after the stream has closed

The current behavior

If the conditions are right the Float call will initiate a write after the stream has closed and there will be a thrown exception

The expected behavior

The Float call is ignored after the stream has closed. There are no errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions