-
-
Couldn't load subscription status.
- Fork 7.4k
Labels
feat: ssrp3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
Providing a proper reproduction for the issue discussed in #19790 (comment)
const server = await createServer({ configFile: false });
const environment = server.environments.ssr;
const url = `/repro-entry.js`;
const id = path.resolve('repro-entry.js');
{
await environment.transformRequest(url);
const mod = environment.moduleGraph.getModuleById(id);
console.log('[1st transformResult]', mod.transformResult); // => (ok)
}
environment.moduleGraph.invalidateAll();
{
// `transformRequest` immediately after `invalidateAll` skips setting `mod.transformResult`.
await environment.transformRequest(url);
const mod = environment.moduleGraph.getModuleById(id);
console.log('[2nd transformResult]', mod.transformResult); // => null
}This is due to 2nd transformRequest's timestamp and lastInvalidationTimestamp happens at the same millisecond.
vite/packages/vite/src/node/server/transformRequest.ts
Lines 438 to 439 in 71227be
| if (timestamp > mod.lastInvalidationTimestamp) | |
| moduleGraph.updateModuleTransformResult(mod, result) |
I think changing condition into timestamp >= mod.lastInvalidationTimestamp is not right either since it can lead to stale when transformRequest and invalidateAll happens at the same time (cf. #7254).
Reproduction
https://stackblitz.com/edit/vitejs-vite-bgq6kwfo?file=repro.js
Steps to reproduce
No response
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.20.3 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
vite: ^6.2.2 => 6.2.5Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
sapphi-red
Metadata
Metadata
Assignees
Labels
feat: ssrp3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)