[Flight] Fix double-incremented pending chunks counter (#31833)
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.
Hendrik Liebau committed
Dec 18, 2024 at 16:35 UTC
7eb8234f7cbeda298fffb1566b5cc771c09eff2e
1 file changed
+1
-1
packages/react-server/src/ReactFlightServer.js
+1
-1
@@ -3810,11 +3810,11 @@ function forwardDebugInfo(
3810
debugInfo: ReactDebugInfo,
3811
) {
3812
for (let i = 0; i < debugInfo.length; i++) {
3813
- request.pendingChunks++;
3813
if (typeof debugInfo[i].time === 'number') {
3814
// When forwarding time we need to ensure to convert it to the time space of the payload.
3815
emitTimingChunk(request, id, debugInfo[i].time);
3816
} else {
3817
+ request.pendingChunks++;
3818
if (typeof debugInfo[i].name === 'string') {
3819
// We outline this model eagerly so that we can refer to by reference as an owner.
3820
// If we had a smarter way to dedupe we might not have to do this if there ends up