From 7093f779b7db2e0fdcb3f41affd76696b783a5fc Mon Sep 17 00:00:00 2001 From: patak <583075+patak-dev@users.noreply.github.com> Date: Sun, 24 Mar 2024 07:28:57 +0100 Subject: [PATCH] fix: avoid SSR requests in waitForRequestIdle (#16246) --- packages/vite/src/node/server/transformRequest.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/server/transformRequest.ts b/packages/vite/src/node/server/transformRequest.ts index 5dc6e3921215af..94e8c124041077 100644 --- a/packages/vite/src/node/server/transformRequest.ts +++ b/packages/vite/src/node/server/transformRequest.ts @@ -183,9 +183,14 @@ async function doTransform( resolved, ) - const depsOptimizer = getDepsOptimizer(config, ssr) - if (!depsOptimizer?.isOptimizedDepFile(id)) { - server._registerRequestProcessing(id, () => result) + if (!ssr) { + // Only register client requests, server.waitForRequestsIdle should + // have been called server.waitForClientRequestsIdle. We can rename + // it as part of the environment API work + const depsOptimizer = getDepsOptimizer(config, ssr) + if (!depsOptimizer?.isOptimizedDepFile(id)) { + server._registerRequestProcessing(id, () => result) + } } return result