Repository navigation
fix(dev): stop the dist watcher once .nuxt/dist is removed - #1729
mikeporterdev wants to merge 1 commit into
Conversation
Insufficient dataLooks like you're new to GitHub - we're delighted you'd like to contribute! 💚 We welcome the thoughtful use of AI tools when contributing, but ask all contributors to follow two core principles:
This is an automated analysis by AgentScan |
commit: |
CLI benchmark
Full report
|
| Setting | Value |
|---|---|
| Baseline | ref:e48e326790618cf268763bc037e1674a958f867a (v4.1.1) |
| Head | local packages/nuxt-cli at a7a097b (v4.1.1) |
| Node | v24.23.0 |
| OS | Linux 7.0.0 (kernel 7.0.0-1020-azure) |
| CPU | INTEL(R) XEON(R) PLATINUM 8573C x 4 |
| Memory | 15.6 GB |
| Load average at start | 0.81, 0.33, 0.16 |
| Run started | 2026-12-04T10:00:01.244Z |
Cold CLI startup
Median of 15 interleaved runs per command, one warmup discarded.
| Command | baseline v4.1.1 median | head v4.1.1 median | Delta | baseline v4.1.1 min / p95 | head v4.1.1 min / p95 |
|---|---|---|---|---|---|
nuxt --version |
64 ms | 65 ms | +1.6% | 61 ms / 67 ms | 61 ms / 68 ms |
nuxt --version (first output byte) |
60 ms | 61 ms | +1.6% | 58 ms / 63 ms | 58 ms / 64 ms |
nuxt --help |
132 ms | 130 ms | -1.5% | 129 ms / 135 ms | 126 ms / 135 ms |
nuxt --help (first output byte) |
127 ms | 125 ms | -1.1% | 125 ms / 130 ms | 122 ms / 131 ms |
nuxt dev --help |
101 ms | 101 ms | -0.1% | 96 ms / 103 ms | 98 ms / 106 ms |
nuxt dev --help (first output byte) |
96 ms | 97 ms | +0.0% | 92 ms / 99 ms | 94 ms / 102 ms |
nuxt <unknown-command> (no-op) |
140 ms | 141 ms | +0.2% | 135 ms / 145 ms | 136 ms / 144 ms |
nuxt <unknown-command> (no-op) (first output byte) |
136 ms | 136 ms | +0.3% | 130 ms / 139 ms | 131 ms / 139 ms |
Module load cost
Counted with a module.registerHooks load hook, compile cache disabled. Counts every JS module actually evaluated on that code path (native addons excluded). Built-ins loaded after bootstrap are counted separately, including the internal modules they load.
| Command | baseline v4.1.1 modules | head v4.1.1 modules | Delta | baseline v4.1.1 source bytes | head v4.1.1 source bytes | Delta | baseline v4.1.1 built-ins | head v4.1.1 built-ins | Delta |
|---|---|---|---|---|---|---|---|---|---|
nuxt --version |
35 | 35 | 0.0% | 312.4 kB | 312.4 kB | 0.0% | 29 | 29 | 0.0% |
nuxt --help |
138 | 138 | 0.0% | 904.3 kB | 904.3 kB | 0.0% | 93 | 93 | 0.0% |
nuxt dev --help |
68 | 68 | 0.0% | 478.9 kB | 478.9 kB | 0.0% | 90 | 90 | 0.0% |
Install footprint and published tarball
Each version installed on its own into an empty project with nothing but @nuxt/cli as a dependency, so the tree is exactly the CLI and its transitive dependencies. npm cache is warm and the registry is only consulted for metadata, so install wall time is indicative, not a network benchmark.
| Metric | baseline v4.1.1 | head v4.1.1 | Delta |
|---|---|---|---|
Direct dependencies of @nuxt/cli |
23 | 23 | 0.0% |
| Packages in the installed tree (unique name@version) | 38 | 38 | 0.0% |
| Unique package names | 38 | 38 | 0.0% |
| Package directories on disk (cross-check) | 32 | 32 | 0.0% |
Installed node_modules on disk |
2.67 MB | 2.68 MB | +0.0% |
| Installed files | 448 | 448 | 0.0% |
| Install wall time (warm npm cache, median of 3) | 1.34 s | 1.33 s | -0.7% |
| Published tarball (packed) | 265.3 kB | 265.3 kB | +0.0% |
| Published tarball (unpacked) | 858.5 kB | 858.6 kB | +0.0% |
| Files in tarball | 108 | 108 | 0.0% |
Interleaved runs on a shared runner: trust the deltas, not the absolute timings. The dev, restart and build suites run locally via pnpm bench:cli.
Merging this PR will not alter performance1 warning
Comparing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1729 +/- ##
=======================================
Coverage ? 85.54%
=======================================
Files ? 191
Lines ? 14153
Branches ? 4812
=======================================
Hits ? 12107
Misses ? 1767
Partials ? 279 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Sorry, this PR was opened by mistake by an overeager Claude agent that was meant to be debugging a local performance problem in my own project. Closing it. Apologies for the noise. |
Problem
On Windows, once
.nuxt/distis deleted under a runningnuxt dev, the dev server never restarts and its memory grows until it OOMs.fs.watchon a directory that has been removed keeps firingrenameevents, about 90k per second on Windows / Node 22 in a standalone repro, and it doesn't stop. Every event passes theexistsSync(distDir)guard and callsscheduleReload, which resets the 25ms debounce. The timer never fires, so the reload never happens. Each call also leaves a pending promise in the debounce's resolve list, and those pile up.Measured on a real app: heap after GC grew ~2MB/s (1.0GB → 2.1GB in 9 minutes) with no restart. The CPU profile was dominated by this handler.
The usual trigger is
nuxt preparerun beside a running dev server (e.g. in a pre-commit typecheck). 4.x already skips theclearBuildDirin that case. Anything else that deletes the build dir (rm -rf .nuxt,git clean, other tooling) still causes the storm.Fix
Close the dist watcher on the first event after the directory is gone. One event is enough to schedule the reload, and
#loadcreates a new watcher for the new instance.Verified by patching the equivalent code into 3.31.2: five delete-and-restart cycles each restarted normally. Without the patch, the second cycle hung and leaked as above. I haven't added a test, because reproducing the storm needs a Windows
fs.watch. Happy to add one if you have a preferred way to simulate it.