Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/facebook/react into hook-na…
Browse files Browse the repository at this point in the history
…ming
  • Loading branch information
kassens committed Sep 1, 2022
2 parents f426964 + 36c908a commit bd5763e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ export function parseModelString(
} else {
const id = parseInt(value.substring(1), 16);
const chunk = getChunk(response, id);
if (chunk._status === PENDING) {
throw new Error(
"We didn't expect to see a forward reference. This is a bug in the React Server.",
);
}
return readChunk(chunk);
}
}
Expand Down
10 changes: 8 additions & 2 deletions packages/react-server-dom-webpack/src/ReactFlightDOMClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ function startReadingFromStream(
}
const buffer: Uint8Array = (value: any);
processBinaryChunk(response, buffer);
return reader.read().then(progress, error);
return reader
.read()
.then(progress)
.catch(error);
}
function error(e) {
reportGlobalError(response, e);
}
reader.read().then(progress, error);
reader
.read()
.then(progress)
.catch(error);
}

function createFromReadableStream(
Expand Down
4 changes: 3 additions & 1 deletion packages/react-server/src/ReactFlightHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export function resetHooksForRequest() {
function readContext<T>(context: ReactServerContext<T>): T {
if (__DEV__) {
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
console.error('Only ServerContext is supported in Flight');
console.error(
'Only createServerContext is supported in Server Components.',
);
}
if (currentCache === null) {
console.error(
Expand Down
2 changes: 1 addition & 1 deletion packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ function abortTask(task: Task, request: Request, errorId: number): void {
// has a single value referencing the error.
const ref = serializeByValueID(errorId);
const processedChunk = processReferenceChunk(request, task.id, ref);
request.completedJSONChunks.push(processedChunk);
request.completedErrorChunks.push(processedChunk);
}

function flushCompletedChunks(
Expand Down
3 changes: 2 additions & 1 deletion scripts/error-codes/codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,6 @@
"435": "Unexpected Suspense handler tag (%s). This is a bug in React.",
"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\".",
"437": "the \"precedence\" prop for links to stylesheets expects to receive a string but received something of type \"%s\" instead.",
"438": "An unsupported type was passed to use(): %s"
"438": "An unsupported type was passed to use(): %s",
"439": "We didn't expect to see a forward reference. This is a bug in the React Server."
}

0 comments on commit bd5763e

Please sign in to comment.