Skip to content

Commit df66aac

Browse files
committed
Serialize references to errors in the error priority queue
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.
1 parent 3b201dd commit df66aac

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 5 additions & 0 deletions
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/src/ReactFlightServer.js

Lines changed: 1 addition & 1 deletion
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(

0 commit comments

Comments
 (0)