Skip to content

Commit bd5763e

Browse files
committed
Merge branch 'main' of https://github.com/facebook/react into hook-naming
2 parents f426964 + 36c908a commit bd5763e

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

packages/react-client/src/ReactFlightClient.js

+5
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ export function parseModelString(
312312
} else {
313313
const id = parseInt(value.substring(1), 16);
314314
const chunk = getChunk(response, id);
315+
if (chunk._status === PENDING) {
316+
throw new Error(
317+
"We didn't expect to see a forward reference. This is a bug in the React Server.",
318+
);
319+
}
315320
return readChunk(chunk);
316321
}
317322
}

packages/react-server-dom-webpack/src/ReactFlightDOMClient.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ function startReadingFromStream(
3535
}
3636
const buffer: Uint8Array = (value: any);
3737
processBinaryChunk(response, buffer);
38-
return reader.read().then(progress, error);
38+
return reader
39+
.read()
40+
.then(progress)
41+
.catch(error);
3942
}
4043
function error(e) {
4144
reportGlobalError(response, e);
4245
}
43-
reader.read().then(progress, error);
46+
reader
47+
.read()
48+
.then(progress)
49+
.catch(error);
4450
}
4551

4652
function createFromReadableStream(

packages/react-server/src/ReactFlightHooks.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export function resetHooksForRequest() {
2626
function readContext<T>(context: ReactServerContext<T>): T {
2727
if (__DEV__) {
2828
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
29-
console.error('Only ServerContext is supported in Flight');
29+
console.error(
30+
'Only createServerContext is supported in Server Components.',
31+
);
3032
}
3133
if (currentCache === null) {
3234
console.error(

packages/react-server/src/ReactFlightServer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ function abortTask(task: Task, request: Request, errorId: number): void {
902902
// has a single value referencing the error.
903903
const ref = serializeByValueID(errorId);
904904
const processedChunk = processReferenceChunk(request, task.id, ref);
905-
request.completedJSONChunks.push(processedChunk);
905+
request.completedErrorChunks.push(processedChunk);
906906
}
907907

908908
function flushCompletedChunks(

scripts/error-codes/codes.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -423,5 +423,6 @@
423423
"435": "Unexpected Suspense handler tag (%s). This is a bug in React.",
424424
"436": "Stylesheet resources need a unique representation in the DOM while hydrating and more than one matching DOM Node was found. To fix, ensure you are only rendering one stylesheet link with an href attribute of \"%s\".",
425425
"437": "the \"precedence\" prop for links to stylesheets expects to receive a string but received something of type \"%s\" instead.",
426-
"438": "An unsupported type was passed to use(): %s"
426+
"438": "An unsupported type was passed to use(): %s",
427+
"439": "We didn't expect to see a forward reference. This is a bug in the React Server."
427428
}

0 commit comments

Comments
 (0)