cli: Having issues with slow responses with `nuxi dev`
Starting with the 3.7.0 release of the nuxi CLI, we added a security fix to prevent exposing the dev server port to the local-area network by default, limiting its access to your computer only.
Initially, using 127.0.0.1 as a localhost IP address tended to work fine on MacOS and Linux operating systems. However, we soon received bug reports indicating that it caused slower builds on Windows, Docker, and WSL2. The reason is that localhost can be resolved to either 127.0.0.1 (IPv4) or ::1 (IPv6), and on some operating systems, they first attempt to use IPv6 (::1) each time. This behavior was not available, and a timeout occurred before falling back to 127.0.0.1, causing slow build issues.
In the latest release of nuxi 3.9 and unjs/listhen via https://github.com/unjs/listhen/pull/126, we have adjusted the defaults to better support Windows, WSL2, and Docker. At least in my homelab Windows VM, it now shows fast builds again when using the default nuxi host and opening it in http://localhost:3000.
If you were previously using any workarounds involving the --host argument or HOST environment variable, please consider removing them and trying again.
You can update to the latest version of nuxi by using nuxi upgrade, or you can try it with npx nuxi@latest dev or bun x nuxi@latest dev. You can ensure you have the latest version by using the nuxi info or nuxi --version commands.
If you continue to experience slow build issues, they may have different causes. In this case, further investigation is necessary.
Please report the issue in this thread along with the full output of the nuxi info command, including your local host information. Also, mention if you are using WSL2 or any custom setup.
About this issue
- Original URL
- State: open
- Created 9 months ago
- Reactions: 12
- Comments: 21 (5 by maintainers)
Thanks for investigation!
For me, build times are always fast (using
ssr: true) however, downloading files (js/css/vue) is very slow onlocalhostwithout--host(which is default setup).without
--host: localhost: 300ms/file (>1minute page refresh in total for not-so-big project) 127.0.0.1: 10ms/filewith
--host: localhost: 10ms/file 127.0.0.1: 10ms/fileHey @pi0,
My small website is now taking 10~mins to build.
I’m happy to provide more information here if you need it. Alternatively, we can chat in discord if it helps. My handle
blowsie.devnuxi dev (even with 3.9.0 version) on Windows 11 and Nodejs 20+ is starting the app very slowly.
Here are the timestamps:
Here is the nuxi info:
Nuxt config
Here is my nuxt config file
Tailwind config
And here is my tailwind config file
Edit: Removing modules (except pwa)
With this in nuxt config
Still, the timestamps hardly show any improvement
Edit: Cleaning the entire nuxt config file
Nuxt config file:
The timestamps improved, but still, aren’t they quite high?
Keeping the nuxt config file clean, I downgraded the Nuxt to 3.7.1 and Nitropack to 2.6.2. Here are the improved timestamps:
Same here, but in Windows don’t use WSL
The fixes in CLI verison 3.9.0 solved the problem for me.
For new projects it works immediately (
npx nuxi@latest init my-app)My previous project, which I had to run with
nuxt dev --host, worked after runningyarn nuxi upgrade --forceI also tried just removing node_modules/ and yarn.lock, which did the trick as well.So the slow loading is resolved for me.
@vladimir_pankov make sure to remove yarn.lock in your project, as nuxi is also cached there and run a fresh yarn install to get cli version 3.9.0 in your project
I do not know dependencies but nitro prints big execution time:
[nitro] ├─ /api/_content/query/k9iRHwiJVs.1695315995949.json (9468ms) [nitro] ├─ /api/_content/query/465KpVz6lY.1695315995949.json (9469ms) [nitro] ├─ /api/_content/query/B8SbwC8dv3.1695315995949.json (9243ms) [nitro] ├─ /api/_content/query/LXc88yZOr0.1695315995949.json (8346ms) [nitro] ├─ /api/_content/query/zPiQGDJdIf.1695315995949.json (8345ms) [nitro] ├─ /api/_content/query/rxDcFyI10a.1695315995949.json (8346ms)
in comparison to old version: [nitro] ├─ /api/_content/query/tF9pmSdcSG.1695310283789.json (216ms) [nitro] ├─ /api/_content/query/NBBzC05jLl.1695310283789.json (204ms) [nitro] ├─ /api/_content/query/W0UzeWBvuu.1695310283789.json (203ms) [nitro] ├─ /api/_content/query/Gg6BrmZ1bO.1695310283789.json (232ms) [nitro] ├─ /api/_content/query/UHnxKwnROu.1695310283789.json (213ms) [nitro] ├─ /api/_content/query/h2C4aJKlkf.1695310283789.json (213ms)
Thanks to more info @stafyniaksacha, there seems to be ~10% overhead in WSL environments from proxy. Meanwhile working on a fix (to use direct IPX Sockets), you might try with
nuxi dev --no-fork.@Dodobibi Sorry to hear that. Currently, we do not have any official way of registering WebSockets but this example might be helpful (and works with all versions of CLI listen hook. Feel free to open an issue with your current code if can’t make it would be happy to help.
@blowsie first you might want to upgrade your CLI to 3.9.x
Hi @pi0 the problem keeps reproducing, just in case I reinstalled win and wsl )
Win hosts
wsl --version
No
C:\Users\<UserName>\.wslconfigWSL2 lsb_release -a
WSL2 etc/hosts
VS Code
VS Code .devcontainer lsb_release -a
npx nuxi info