Skip to content

Commit

Permalink
[Flight] Fix double-incremented pending chunks counter (#31833)
Browse files Browse the repository at this point in the history
Before calling `emitTimingChunk` inside of `forwardDebugInfo`, we must
not increment `request.pendingChunks`, as this is already done inside of
the `emitTimingChunk` function.

I don't have a unit test for this, but manually verified that this fixes
the hanging responses in vercel/next.js#73804.
  • Loading branch information
unstubbable authored Dec 18, 2024
1 parent 2bd1c75 commit 7eb8234
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3810,11 +3810,11 @@ function forwardDebugInfo(
debugInfo: ReactDebugInfo,
) {
for (let i = 0; i < debugInfo.length; i++) {
request.pendingChunks++;
if (typeof debugInfo[i].time === 'number') {
// When forwarding time we need to ensure to convert it to the time space of the payload.
emitTimingChunk(request, id, debugInfo[i].time);
} else {
request.pendingChunks++;
if (typeof debugInfo[i].name === 'string') {
// We outline this model eagerly so that we can refer to by reference as an owner.
// If we had a smarter way to dedupe we might not have to do this if there ends up
Expand Down

0 comments on commit 7eb8234

Please sign in to comment.