Skip to content

fix: warm Vite entries before exposing dev server#61

Merged
abewheel merged 1 commit into
mainfrom
abewheel/vite-warmup
May 6, 2026
Merged

fix: warm Vite entries before exposing dev server#61
abewheel merged 1 commit into
mainfrom
abewheel/vite-warmup

Conversation

@abewheel
Copy link
Copy Markdown
Contributor

@abewheel abewheel commented May 6, 2026

Summary

Vite's depsOptimizer.entries scan kicks off on server creation but doesn't block request handling, so the first inspector iframe load can race the optimizer and produce a 504 with a blank widget. This change calls warmupRequest() for every resource and tool entry in parallel, then awaits waitForRequestsIdle() before runMCPServer starts, so pre-bundling has fully settled before any host can hit the server. Adds ~300ms to startup against the template (4 resources + 7 tools); skipped under --prod-resources where mcpViteServer is created but unused. Production servers (production-server.ts) have no Vite in the loop and are unaffected.

Test plan

  • pnpm --filter sunpeak lint
  • pnpm --filter sunpeak typecheck
  • pnpm --filter sunpeak test -- --run (367 passed)
  • Booted sunpeak dev against the template — logged Warmed Vite (11 entries) in 315ms, MCP listened, inspector connected

Vite's depsOptimizer.entries scan kicks off on server creation but doesn't
block request handling, so the first inspector iframe load can race the
optimizer and produce a 504 with a blank widget — exactly when a developer
is forming a first impression. Warm each resource and tool entry, then await
requests-idle, before runMCPServer starts. Adds ~300ms to startup against
the template (4 resources + 7 tools); skipped under --prod-resources where
the Vite server isn't used.
@abewheel abewheel merged commit 56ab78f into main May 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant