N
Nuxt3d ago
McSneaky

Dev server reloads take about a minute and do close to 1k requests

I haven't been on a project for some days and now suddenly dev server takes about a minute to load on each refresh It comes down to nr of requests, it does about 1k requests. With cache enabled it comes down to "just" about 45 sec, with cache disabled it's around 50-70 sec Is there a way to make it more snappy? Don't even know where to start investigating. Some config value somewhere most likely Edit: Running on 64G of RAM and Ryzen 7950X and Nuxt version 3.15.4
No description
No description
3 Replies
kapa.ai
kapa.ai3d ago
Hi @McSneaky. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I understand your frustration with slow dev server reload times. This is a common performance issue with Nuxt development servers, especially in larger projects. Let me help you understand what might be happening and suggest some solutions. Possible Causes The slow reload times and high number of requests are likely related to how Nuxt handles development mode, particularly with Vite as the builder. Several issues in the knowledge sources point to similar problems: 1. All pages being preloaded: In development mode, Vite may load all pages and components at once, even if they're not needed for the current route GitHub Issue #31100. 2. HMR (Hot Module Replacement) recompiling too many files: When you change a single file, Nuxt might be recompiling all templates from all modules multiple times GitHub Issue #30290. Solutions to Try Here are some approaches that might help improve your development experience: 1. Enable Build Cache (Experimental) Nuxt has an experimental build cache feature that can significantly improve rebuild times:
// nuxt.config.ts
export default defineNuxtConfig({
experimental: {
buildCache: true
}
})
// nuxt.config.ts
export default defineNuxtConfig({
experimental: {
buildCache: true
}
})
This caches build outputs and only rebuilds what's necessary when files change GitHub Pull #28726. 2. Check Your Middleware Middleware that runs on both server and client can cause performance issues. Try to limit middleware execution to where it's needed:
// In your middleware
if (import.meta.server) {
return; // Skip on server
}
// In your middleware
if (import.meta.server) {
return; // Skip on server
}
Or for client-side:
if (import.meta.client) {
// Only run on client
}
if (import.meta.client) {
// Only run on client
}
3. Use Nuxt DevTools to Identify Bottlenecks The Hooks tab in Nuxt DevTools can help you monitor time spent in each hook, which might help identify performance bottlenecks Nuxt DevTools. 4. Check for Recent Updates If this started happening suddenly, check if you recently updated Nuxt or any modules. Some users reported significant HMR slowdowns after updating to specific versions GitHub Issue #30290. 5. Optimize Your Project Structure - Consider splitting your app into smaller, more manageable components - Reduce the number of async components if possible - Check if any modules are causing the slowdown (try temporarily disabling non-essential modules) 6. Production Build for Testing While not ideal for development, you could build for production to test if your app works correctly without the development overhead:
npm run build
npm run preview
npm run build
npm run preview
Recent Improvements The Nuxt team is aware of these performance issues and has been working on improvements: - Deferring version/config checks until after Vite build GitHub Pull #30567 - Starting warmups after Nitro build GitHub Pull #27963 - Unsubscribing from asyncData watch when components unmount GitHub Pull #26821 If you're still experiencing issues after trying these solutions, you might want to create a minimal reproduction of your project and open an issue on the Nuxt GitHub repository. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@224232055775559681> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
McSneaky
McSneakyOP3d ago
Tried that experimental thingy, didn't help It seems to be something related to Windows. Rebooted under Linux and now it loads within a second. It still does just under 1k requests, but they all happen a lot faster

Did you find this page helpful?