From 5bfc3762e2de85844bc076a5db8a6efb55bf34f4 Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Wed, 18 Dec 2024 14:13:35 +0100 Subject: [PATCH] [Flight] Fix double-incremented pending chunks counter 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 https://github.com/vercel/next.js/pull/73804. --- packages/react-server/src/ReactFlightServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-server/src/ReactFlightServer.js b/packages/react-server/src/ReactFlightServer.js index 42ffdf1ef0d2..5a27f006179b 100644 --- a/packages/react-server/src/ReactFlightServer.js +++ b/packages/react-server/src/ReactFlightServer.js @@ -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