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