Skip to content

Commit

Permalink
Serialize references to errors in the error priority queue
Browse files Browse the repository at this point in the history
It doesn't make sense to emit references to future values at higher pri
than the value that they're referencing.

This ensures that we don't emit hard forward references to values that
don't yet exist.
  • Loading branch information
sebmarkbage committed Aug 29, 2022
1 parent 3b201dd commit df66aac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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
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

0 comments on commit df66aac

Please sign in to comment.