Skip to content

Conversation

@unstubbable
Copy link
Collaborator

The WebSocketStream implementation seems to be a bit unreliable. We've seen Cannot close a ERRORED writable stream errors when expanding the logged deep object, for example. And when reducing the fixture to a minimal app, we even get Connection closed errors, because the web socket connection is closed before all debug chunks are sent.

We can improve the reliability of the web socket connection by using a normal WebSocket instance on the client, along with manually creating a WritableStream and a ReadableStream for processing the messages.

As an additional benefit, the debug channel now also works in Firefox and Safari.

On the server, we're simplifying the integration with the Express server a bit by utilizing the server property for WebSocket.Server, instead of the noServer property with the manual upgrade handling.

The `WebSocketStream` implementation seems to be a bit unreliable. We've
seen `Cannot close a ERRORED writable stream` errors when expanding the
logged deep object, for example. And when reducing the fixture to a
minimal app, we even get `Connection closed` errors, because the web
socket connection is closed before all debug chunks are sent.

We can improve the reliability of the web socket connection by using a
normal `WebSocket` instance on the client, along with manually creating
a `WritableStream` and a `ReadableStream` for processing the messages.

As an additional benefit, the debug channel now also works in Firefox
and Safari.

On the server, we're simplifying the integration with the Express server
a bit by utilizing the `server` property for `WebSocket.Server`, instead
of the `noServer` property with the manual upgrade handling.
@meta-cla meta-cla bot added the CLA Signed label Aug 29, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Aug 29, 2025
@react-sizebot
Copy link

Comparing: 4082b0e...0a55f2d

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 530.31 kB 530.31 kB = 93.39 kB 93.39 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 657.78 kB 657.78 kB = 115.66 kB 115.66 kB
facebook-www/ReactDOM-prod.classic.js = 677.76 kB 677.76 kB = 118.94 kB 118.94 kB
facebook-www/ReactDOM-prod.modern.js = 668.19 kB 668.19 kB = 117.26 kB 117.26 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 0a55f2d

@unstubbable unstubbable marked this pull request as ready for review August 29, 2025 09:48
@unstubbable unstubbable requested a review from eps1lon August 29, 2025 09:48
@unstubbable unstubbable merged commit 3fe51c9 into facebook:main Aug 29, 2025
250 checks passed
@unstubbable unstubbable deleted the more-rebust-web-socket branch August 29, 2025 10:04
github-actions bot pushed a commit to code/lib-react that referenced this pull request Aug 31, 2025
…ok#34338)

The `WebSocketStream` implementation seems to be a bit unreliable. We've
seen `Cannot close a ERRORED writable stream` errors when expanding the
logged deep object, for example. And when reducing the fixture to a
minimal app, we even get `Connection closed` errors, because the web
socket connection is closed before all debug chunks are sent.

We can improve the reliability of the web socket connection by using a
normal `WebSocket` instance on the client, along with manually creating
a `WritableStream` and a `ReadableStream` for processing the messages.

As an additional benefit, the debug channel now also works in Firefox
and Safari.

On the server, we're simplifying the integration with the Express server
a bit by utilizing the `server` property for `WebSocket.Server`, instead
of the `noServer` property with the manual upgrade handling.

DiffTrain build for [3fe51c9](facebook@3fe51c9)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Aug 31, 2025
…ok#34338)

The `WebSocketStream` implementation seems to be a bit unreliable. We've
seen `Cannot close a ERRORED writable stream` errors when expanding the
logged deep object, for example. And when reducing the fixture to a
minimal app, we even get `Connection closed` errors, because the web
socket connection is closed before all debug chunks are sent.

We can improve the reliability of the web socket connection by using a
normal `WebSocket` instance on the client, along with manually creating
a `WritableStream` and a `ReadableStream` for processing the messages.

As an additional benefit, the debug channel now also works in Firefox
and Safari.

On the server, we're simplifying the integration with the Express server
a bit by utilizing the `server` property for `WebSocket.Server`, instead
of the `noServer` property with the manual upgrade handling.

DiffTrain build for [3fe51c9](facebook@3fe51c9)
EugeneChoi4 pushed a commit to EugeneChoi4/react that referenced this pull request Sep 4, 2025
…ok#34338)

The `WebSocketStream` implementation seems to be a bit unreliable. We've
seen `Cannot close a ERRORED writable stream` errors when expanding the
logged deep object, for example. And when reducing the fixture to a
minimal app, we even get `Connection closed` errors, because the web
socket connection is closed before all debug chunks are sent.

We can improve the reliability of the web socket connection by using a
normal `WebSocket` instance on the client, along with manually creating
a `WritableStream` and a `ReadableStream` for processing the messages.

As an additional benefit, the debug channel now also works in Firefox
and Safari.

On the server, we're simplifying the integration with the Express server
a bit by utilizing the `server` property for `WebSocket.Server`, instead
of the `noServer` property with the manual upgrade handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants