From c63f67830f68ff576d475f69cf734215d5483ef6 Mon Sep 17 00:00:00 2001 From: Josh Larson Date: Wed, 19 Jan 2022 15:36:28 -0600 Subject: [PATCH] wip: fix reentrant error with ReadableStreams in RSC --- .../esm/react-server-dom-vite-writer.browser.server.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/hydrogen/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js b/packages/hydrogen/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js index c6ad3b655e..8ec64afa69 100644 --- a/packages/hydrogen/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +++ b/packages/hydrogen/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js @@ -839,7 +839,10 @@ function performWork(request) { } } +let reentrant = false; function flushCompletedChunks(request, destination) { + if (reentrant) return; + reentrant = true; try { // We emit module chunks first in the stream so that // they can be preloaded as early as possible. @@ -893,6 +896,7 @@ function flushCompletedChunks(request, destination) { errorChunks.splice(0, i); } finally { + reentrant = false; } if (request.pendingChunks === 0) {