Skip to content

Commit f646e8f

Browse files
authored
[Flight] Fix hasReadable flag in Node.js clients' debug channel (facebook#35039)
For Edge Flight servers, that use Web Streams, we're defining the `debugChannel` option as: ``` debugChannel?: {readable?: ReadableStream, writable?: WritableStream, ...} ``` Whereas for Node.js Flight servers, that use Node.js Streams, we're defining it as: ``` debugChannel?: Readable | Writable | Duplex | WebSocket ``` For the Edge Flight clients, there is currently only one direction of the debug channel supported, so we define the option as: ``` debugChannel?: {readable?: ReadableStream, ...} ``` Consequently, for the Node.js Flight clients, we define the option as: ``` debugChannel?: Readable ``` The presence of a readable debug channel is passed to the Flight client internally via the `hasReadable` flag on the internal `debugChannel` option. For the Node.js clients, that flag was accidentally derived from the public option `debugChannel.readable`, which is conceptually incorrect, because `debugChannel` is a `Readable` stream, not an options object with a `readable` property. However, a `Readable` also has a `readable` property, which is a boolean that indicates whether the stream is in a readable state. This meant that the `hasReadable` flag was incidentally still set correctly. Regardless, this was confusing and unintentional, so we're now fixing it to always set `hasReadable` to `true` when a `debugChannel` is provided to the Node.js clients. We'll revisit this in case we ever add support for writable debug channels in Node.js (and Edge) clients.
1 parent edd05f1 commit f646e8f

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

packages/react-server-dom-esm/src/client/ReactFlightDOMClientNode.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ function createFromNodeStream<T>(
9393
): Thenable<T> {
9494
const debugChannel: void | DebugChannel =
9595
__DEV__ && options && options.debugChannel !== undefined
96-
? {
97-
hasReadable: options.debugChannel.readable !== undefined,
98-
callback: null,
99-
}
96+
? {hasReadable: true, callback: null}
10097
: undefined;
10198

10299
const response: Response = createResponse(

packages/react-server-dom-parcel/src/client/ReactFlightDOMClientNode.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ export function createFromNodeStream<T>(
8686
): Thenable<T> {
8787
const debugChannel: void | DebugChannel =
8888
__DEV__ && options && options.debugChannel !== undefined
89-
? {
90-
hasReadable: options.debugChannel.readable !== undefined,
91-
callback: null,
92-
}
89+
? {hasReadable: true, callback: null}
9390
: undefined;
9491

9592
const response: Response = createResponse(

packages/react-server-dom-turbopack/src/client/ReactFlightDOMClientNode.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ function createFromNodeStream<T>(
9595
): Thenable<T> {
9696
const debugChannel: void | DebugChannel =
9797
__DEV__ && options && options.debugChannel !== undefined
98-
? {
99-
hasReadable: options.debugChannel.readable !== undefined,
100-
callback: null,
101-
}
98+
? {hasReadable: true, callback: null}
10299
: undefined;
103100

104101
const response: Response = createResponse(

packages/react-server-dom-webpack/src/client/ReactFlightDOMClientNode.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ function createFromNodeStream<T>(
9595
): Thenable<T> {
9696
const debugChannel: void | DebugChannel =
9797
__DEV__ && options && options.debugChannel !== undefined
98-
? {
99-
hasReadable: options.debugChannel.readable !== undefined,
100-
callback: null,
101-
}
98+
? {hasReadable: true, callback: null}
10299
: undefined;
103100

104101
const response: Response = createResponse(

0 commit comments

Comments
 (0)