What this thread does
For 504 (Outdated Optimize Dep), rebuild Vite's dependency prebundle and reload with browser caching disabled.
The development page goes blank while an optimized dependency request fails.
Do first: stop the dev server, disable cache in the browser Network panel, then start the project's Vite binary with pnpm exec vite --force and reload after optimization finishes.
Evidence supports this cache reset procedure, not a universal fix for every optimizer race. Not for: lazy-import TypeError or EISDIR query handling; see vite-call-typeerror-lazy-imports-eisdir-query-link.
Diagnostic: 504 (Outdated Optimize Dep)
1. Inspect the failed request: this recipe concerns development requests for optimized dependencies, commonly under node_modules/.vite/deps. A reverse proxy's generic 504 needs separate diagnosis. 2. Use the project's existing dev script if it sets a root, mode or config; pass --force through that script instead of dropping its arguments. Keep one server for the test. 3. Reload the failing route with cache disabled. Vite documents both a filesystem prebundle cache and strongly cached browser dependency requests. A server restart alone need not refresh both. Vite caching guide, checked 2026-10-28. 4. If the failure returns on a particular route, record the dependency/import that triggers another optimization. Plugin-generated imports can escape the initial scan. Add that specific package to optimizeDeps.include when it is large or CommonJS. A linked CommonJS package also needs explicit inclusion. Discovery and linked dependencies. 5. A small valid ESM dependency can instead be excluded. Do not exclude CommonJS; include a nested CommonJS dependency explicitly if its ESM parent is excluded. Optimizer settings.
Example for an identified package; replace problem-package with its actual import name:
import { defineConfig } from 'vite';
export default defineConfig({
optimizeDeps: { include: ['problem-package'] }
});
Restart with --force after this edit. Verify the formerly failing route twice, then make a normal source edit and verify hot reload. If failure persists, preserve the lockfile and make a minimal reproduction with the exact Vite, plugin and package versions. These are proposed acceptance checks, not reported test results.
Which action fits?
| Action | Wins when | Loses when | Cost or limit; pick this if |
|---|---|---|---|
| One forced rebuild plus browser reload | Cached development output is stale | The same import consistently reproduces a race | No hosted-service charge; redoes optimization. Pick this for a one-off dependency change. |
| Explicit include/exclude | Imports are discovered late or a linked dependency needs prebundling | The problem is an unrelated runtime error | Configuration maintenance; CommonJS must remain optimized. Pick this only after identifying the import. |
Recommendations: solo developer, start with the reset; small team, commit only a demonstrated import-discovery correction; enterprise, reproduce with the shared lockfile and plugins before changing team-wide optimizer settings. These are editorial recommendations.
Public evidence
Issue 14284, anyesu, 2023-09-04: “the page displays a white screen”. The report itself involved --force, so that flag is not proof that an underlying race is solved. Discussion 15833, dilanka-cacib, 2024-03-14: “my app still fails to run”. That worker-import case warns against adding broad glob patterns blindly. Historical reports are not current-version compatibility guarantees.
Prompt for your agent
Inspect the failing optimized-dependency URL, preserve the lockfile, reset the documented caches, and identify the import that triggers re-optimization. Propose the narrowest include/exclude change and show the before/after route check.
Mistakes and limits
Do not delete the lockfile or reinstall every dependency as the first action. Prebundling is a development feature; this does not diagnose production asset deployment failures. No reproduction, browser run or performance measurement was performed. No fixed-in release is established for the user's unknown version. checked 2026-10-28
Started from a post by @Vite contributors, packaged by the editor. Original post