From d94eb6cfb16df3f2f5a0adca4ed55123772615dd Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 3 Oct 2025 14:42:41 +0900 Subject: [PATCH] fix(dev): remove timestamp query consistently --- .../vite/src/node/server/transformRequest.ts | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/vite/src/node/server/transformRequest.ts b/packages/vite/src/node/server/transformRequest.ts index e6a15e583cd672..2dd0d38cfeec8f 100644 --- a/packages/vite/src/node/server/transformRequest.ts +++ b/packages/vite/src/node/server/transformRequest.ts @@ -99,25 +99,25 @@ export function transformRequest( // last time this module is invalidated const timestamp = monotonicDateNow() + url = removeTimestampQuery(url) + const pending = environment._pendingRequests.get(url) if (pending) { - return environment.moduleGraph - .getModuleByUrl(removeTimestampQuery(url)) - .then((module) => { - if (!module || pending.timestamp > module.lastInvalidationTimestamp) { - // The pending request is still valid, we can safely reuse its result - return pending.request - } else { - // Request 1 for module A (pending.timestamp) - // Invalidate module A (module.lastInvalidationTimestamp) - // Request 2 for module A (timestamp) - - // First request has been invalidated, abort it to clear the cache, - // then perform a new doTransform. - pending.abort() - return transformRequest(environment, url, options) - } - }) + return environment.moduleGraph.getModuleByUrl(url).then((module) => { + if (!module || pending.timestamp > module.lastInvalidationTimestamp) { + // The pending request is still valid, we can safely reuse its result + return pending.request + } else { + // Request 1 for module A (pending.timestamp) + // Invalidate module A (module.lastInvalidationTimestamp) + // Request 2 for module A (timestamp) + + // First request has been invalidated, abort it to clear the cache, + // then perform a new doTransform. + pending.abort() + return transformRequest(environment, url, options) + } + }) } const request = doTransform(environment, url, options, timestamp) @@ -147,8 +147,6 @@ async function doTransform( options: TransformOptionsInternal, timestamp: number, ) { - url = removeTimestampQuery(url) - const { pluginContainer } = environment let module = await environment.moduleGraph.getModuleByUrl(url)