fix: avoid outdated module to crash in importAnalysis after restart#13231
fix: avoid outdated module to crash in importAnalysis after restart#13231
Conversation
|
|
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
| const pending = server._pendingRequests.get(cacheKey) | ||
| if (pending) { | ||
| return server.moduleGraph | ||
| .getModuleByUrl(removeTimestampQuery(url), options.ssr) |
There was a problem hiding this comment.
Unrelated to the PR, the timestamp is already removed by getModuleByUrl. We can move it to a separate PR if it is too noisy here
There was a problem hiding this comment.
I wouldn't mind mixing it here as it's only few line changes, so I'm fine either ways 🙂
| const importerModule = moduleGraph.getModuleById(importer)! | ||
| if (!importerModule && depsOptimizer?.isOptimizedDepFile(importer)) { | ||
| // Ids of optimized deps could be invalidated and removed from the graph | ||
| // Return without transforming, this request is no longer valid, a full reload | ||
| if (!importerModule) { | ||
| // When the server is restarted, the module graph is cleared, so we | ||
| // return without transforming. This request is no longer valid, a full reload | ||
| // is going to request this id again. Throwing an outdated error so we | ||
| // properly finish the request with a 504 sent to the browser. | ||
| throwOutdatedRequest(importer) |
There was a problem hiding this comment.
This should be the fix for #13030, the rest of the PR are extra guards I think we should also apply.
|
The issue is that This line makes vite/packages/vite/src/node/server/index.ts Line 851 in 0cbd818 I think we have code like this in some code paths: const module = await server.moduleGraph.ensureModuleByUrl(...)
...
await server.moduleGraph.getModuleByUrl(url)This would be fine if we always use the same |
Description
wip potential fix for #13030
What is the purpose of this pull request?