Skip to content

Commit 521f26c

Browse files
committed
Integrate review feedback
1 parent a6f053d commit 521f26c

File tree

12 files changed

+64
-45
lines changed

12 files changed

+64
-45
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,10 @@ export type FindSourceMapURLCallback = (
341341

342342
export type DebugChannelCallback = (message: string) => void;
343343

344-
export interface DebugChannel {
345-
hasReadable: boolean;
346-
callback?: DebugChannelCallback;
347-
}
344+
export type DebugChannel = {
345+
hasReadable: boolean,
346+
callback: DebugChannelCallback | null,
347+
};
348348

349349
type Response = {
350350
_bundlerConfig: ServerConsumerModuleMap,
@@ -367,7 +367,7 @@ type Response = {
367367
_debugRootStack?: null | Error, // DEV-only
368368
_debugRootTask?: null | ConsoleTask, // DEV-only
369369
_debugFindSourceMapURL?: void | FindSourceMapURLCallback, // DEV-only
370-
_debugChannel?: void | DebugChannel, // DEV-only
370+
_debugChannel?: null | DebugChannel, // DEV-only
371371
_blockedConsole?: null | SomeChunk<ConsoleEntry>, // DEV-only
372372
_replayConsole: boolean, // DEV-only
373373
_rootEnvironmentName: string, // DEV-only, the requested environment name.
@@ -1009,11 +1009,11 @@ export function reportGlobalError(
10091009
});
10101010
if (__DEV__) {
10111011
const debugChannel = response._debugChannel;
1012-
if (debugChannel !== undefined) {
1012+
if (debugChannel != null) {
10131013
// If we don't have any more ways of reading data, we don't have to send any
10141014
// more neither. So we close the writable side.
10151015
closeDebugChannel(debugChannel);
1016-
response._debugChannel = undefined;
1016+
response._debugChannel = null;
10171017
}
10181018
}
10191019
}
@@ -1499,8 +1499,7 @@ function waitForReference<T>(
14991499
): T {
15001500
if (
15011501
__DEV__ &&
1502-
(response._debugChannel === undefined ||
1503-
!response._debugChannel.hasReadable)
1502+
(response._debugChannel == null || !response._debugChannel.hasReadable)
15041503
) {
15051504
if (
15061505
referencedChunk.status === PENDING &&
@@ -2429,7 +2428,7 @@ function ResponseInstance(
24292428
// We can't safely clean things up later, so we immediately close the
24302429
// debug channel.
24312430
closeDebugChannel(debugChannel);
2432-
this._debugChannel = undefined;
2431+
this._debugChannel = null;
24332432
} else {
24342433
// When a Response gets GC:ed because nobody is referring to any of the
24352434
// objects that lazily load from the Response anymore, then we can close
@@ -3555,8 +3554,7 @@ function resolveDebugModel(
35553554
if (
35563555
__DEV__ &&
35573556
((debugChunk: any): SomeChunk<any>).status === BLOCKED &&
3558-
(response._debugChannel === undefined ||
3559-
!response._debugChannel.hasReadable)
3557+
(response._debugChannel == null || !response._debugChannel.hasReadable)
35603558
) {
35613559
if (json[0] === '"' && json[1] === '$') {
35623560
const path = json.slice(2, json.length - 1).split(':');

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function createDebugCallbackFromWritableStream(
7373
}
7474

7575
function createResponseFromOptions(options: void | Options) {
76-
const debugChannel: void | DebugChannel =
76+
const debugChannel: null | DebugChannel =
7777
__DEV__ && options && options.debugChannel !== undefined
7878
? {
7979
hasReadable: options.debugChannel.readable !== undefined,
@@ -82,9 +82,9 @@ function createResponseFromOptions(options: void | Options) {
8282
? createDebugCallbackFromWritableStream(
8383
options.debugChannel.writable,
8484
)
85-
: undefined,
85+
: null,
8686
}
87-
: undefined;
87+
: null;
8888

8989
return createResponse(
9090
options && options.moduleBaseURL ? options.moduleBaseURL : '',

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ function createFromNodeStream<T>(
8989
moduleBaseURL: string,
9090
options?: Options,
9191
): Thenable<T> {
92-
const debugChannel: void | DebugChannel =
92+
const debugChannel: null | DebugChannel =
9393
__DEV__ && options && options.debugChannel !== undefined
94-
? {hasReadable: options.debugChannel.readable !== undefined}
95-
: undefined;
94+
? {
95+
hasReadable: options.debugChannel.readable !== undefined,
96+
callback: null,
97+
}
98+
: null;
9699

97100
const response: Response = createResponse(
98101
moduleRootPath,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function createDebugCallbackFromWritableStream(
101101
}
102102

103103
function createResponseFromOptions(options: void | Options) {
104-
const debugChannel: void | DebugChannel =
104+
const debugChannel: null | DebugChannel =
105105
__DEV__ && options && options.debugChannel !== undefined
106106
? {
107107
hasReadable: options.debugChannel.readable !== undefined,
@@ -110,9 +110,9 @@ function createResponseFromOptions(options: void | Options) {
110110
? createDebugCallbackFromWritableStream(
111111
options.debugChannel.writable,
112112
)
113-
: undefined,
113+
: null,
114114
}
115-
: undefined;
115+
: null;
116116

117117
return createResponse(
118118
null, // bundlerConfig

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ export type Options = {
8484
};
8585

8686
function createResponseFromOptions(options?: Options) {
87-
const debugChannel: void | DebugChannel =
87+
const debugChannel: null | DebugChannel =
8888
__DEV__ && options && options.debugChannel !== undefined
89-
? {hasReadable: options.debugChannel.readable !== undefined}
90-
: undefined;
89+
? {
90+
hasReadable: options.debugChannel.readable !== undefined,
91+
callback: null,
92+
}
93+
: null;
9194

9295
return createResponse(
9396
null, // bundlerConfig

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ export function createFromNodeStream<T>(
8282
stream: Readable,
8383
options?: Options,
8484
): Thenable<T> {
85-
const debugChannel: void | DebugChannel =
85+
const debugChannel: null | DebugChannel =
8686
__DEV__ && options && options.debugChannel !== undefined
87-
? {hasReadable: options.debugChannel.readable !== undefined}
88-
: undefined;
87+
? {
88+
hasReadable: options.debugChannel.readable !== undefined,
89+
callback: null,
90+
}
91+
: null;
8992

9093
const response: Response = createResponse(
9194
null, // bundlerConfig

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function createDebugCallbackFromWritableStream(
7272
}
7373

7474
function createResponseFromOptions(options: void | Options) {
75-
const debugChannel: void | DebugChannel =
75+
const debugChannel: null | DebugChannel =
7676
__DEV__ && options && options.debugChannel !== undefined
7777
? {
7878
hasReadable: options.debugChannel.readable !== undefined,
@@ -81,9 +81,9 @@ function createResponseFromOptions(options: void | Options) {
8181
? createDebugCallbackFromWritableStream(
8282
options.debugChannel.writable,
8383
)
84-
: undefined,
84+
: null,
8585
}
86-
: undefined;
86+
: null;
8787

8888
return createResponse(
8989
null,

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ export type Options = {
8484
};
8585

8686
function createResponseFromOptions(options: Options) {
87-
const debugChannel: void | DebugChannel =
87+
const debugChannel: null | DebugChannel =
8888
__DEV__ && options && options.debugChannel !== undefined
89-
? {hasReadable: options.debugChannel.readable !== undefined}
90-
: undefined;
89+
? {
90+
hasReadable: options.debugChannel.readable !== undefined,
91+
callback: null,
92+
}
93+
: null;
9194

9295
return createResponse(
9396
options.serverConsumerManifest.moduleMap,

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,13 @@ function createFromNodeStream<T>(
9191
serverConsumerManifest: ServerConsumerManifest,
9292
options?: Options,
9393
): Thenable<T> {
94-
const debugChannel: void | DebugChannel =
94+
const debugChannel: null | DebugChannel =
9595
__DEV__ && options && options.debugChannel !== undefined
96-
? {hasReadable: options.debugChannel.readable !== undefined}
97-
: undefined;
96+
? {
97+
hasReadable: options.debugChannel.readable !== undefined,
98+
callback: null,
99+
}
100+
: null;
98101

99102
const response: Response = createResponse(
100103
serverConsumerManifest.moduleMap,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function createDebugCallbackFromWritableStream(
7272
}
7373

7474
function createResponseFromOptions(options: void | Options) {
75-
const debugChannel: void | DebugChannel =
75+
const debugChannel: null | DebugChannel =
7676
__DEV__ && options && options.debugChannel !== undefined
7777
? {
7878
hasReadable: options.debugChannel.readable !== undefined,
@@ -81,9 +81,9 @@ function createResponseFromOptions(options: void | Options) {
8181
? createDebugCallbackFromWritableStream(
8282
options.debugChannel.writable,
8383
)
84-
: undefined,
84+
: null,
8585
}
86-
: undefined;
86+
: null;
8787

8888
return createResponse(
8989
null,

0 commit comments

Comments
 (0)