fix: devtools is causing a severe memory leak
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 44/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- node.js, nuxt, typescript
Línea de trabajo
Empieza reproduciendo la fuga con la secuencia proporcionada nuxi init y npm run dev en Windows con Node v22+, y después compara las ejecuciones con las devtools activadas y desactivadas. Inspecciona los snapshots alrededor de unstorage/readdirp, readable-stream y defineNuxtSchema, incluido el reinicio provocado por nuxt.config.ts; se considera terminado cuando los inicios repetidos del servidor de desarrollo ya no muestran un crecimiento ilimitado de memoria ni un uso anómalo de la CPU.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🐛 The bug
Creating a bare Nuxt project with npx nuxi@latest init project and starting it with npm run dev causes severe memory leak (most of the time). This happens on Windows with Node v22+. This happens on a bare Nuxt starter with no additional Nuxt modules or npm packages added. Importantly, the memory leak occurs without any incoming requests happening or the app open in a browser. You only need to npm run dev after doing the nuxi project init and it will start leaking immediately. This is going to be a pain in the ass because I noticed it usually doesn't happen on the first run of npm run dev but if you stop the dev server and run the command again it will happen (you know you have it when the CPU is high and the memory starts incrementing).
I believe this is different than https://github.com/nuxt/nuxt/issues/30164 as that is in a built project with requests.
Observations:
- It does not leak when building and running
npm run preview. - Requests to the dev server are not needed to leak memory.
- Disabling devtools prevents the memory leak.
- It does not leak every time the dev server is started, maybe 10% of the time it will run normally on the bare project.
- It also leaks with Node v22.12.0 in addition to v23.3.0.
- Abnormally high CPU usage is occurring.
- It ticks up by 2.7-2.9 MB per second.
Proof
These images were taken after enabling/disabling Nuxt devtools and running npm run dev and waiting for exactly 5 minutes.
devtools: { enabled: true }
devtools: { enabled: false}
Snapshots
These make it seem like there is something with \node_modules\unstorage\node_modules\readdirp\index.js and/or are-we-there-yet\node_modules\readable-stream. But also defineNuxtSchema.
Here's how I did this:
npx nuxi dev --inspectwith devtools disabled- Open Chrome and go to
chrome://inspectand inspect the Node project - Let it run 5 minutes, collect garbage and take another snapshot (Snapshot 1, control)
- Edit
nuxt.config.tsand enable devtools, let it restart with HMR - Let it run 10 minutes, then collect garbage and take another snapshot (Snapshot 2)
- Let it run 10 more minutes, then collect garbage and take final snapshot (Snapshot 3)
Snapshot 2 vs Snapshot 3 (devtools enabled short vs longer leak)
Full reproduction
Since I don't think stackblitz is going to show this issue:
npx nuxi init@latest projectcd projectnpm run dev- Quit the process and re-run
npm run dev - Observe memory leak
npx nuxi devtools disablenpm run dev- Observe no memory leak
🛠️ To reproduce
https://stackblitz.com/edit/github-4exzk3tl
🌈 Expected behavior
devtools should not be causing a memory leak in a bare project created with npx nuxi@latest init project
ℹ️ Additional context
npx nuxi info
- Operating System: Windows_NT
- Node Version: v23.3.0
- Nuxt Version: 3.14.1592
- CLI Version: 3.16.0
- Nitro Version: 2.10.4
- Package Manager: npm@10.9.1
- Builder: -
- User Config: default
- Runtime Modules: -
- Build Modules: -
Full nuxt.config.ts (devtools enabled)
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: {
enabled: true,
timeline: { enabled: true },
},
compatibilityDate: '2024-11-01',
})
Full nuxt.config.ts (devtools disabled)
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: {
enabled: false,
timeline: { enabled: true },
},
compatibilityDate: '2024-11-01',
})
- Lenguaje dominante
- TypeScript
- Estrellas
- 3.3k
- Forks
- 214
- Merge medio
- 19 h 45 min
- PR fusionados (30 d)
- 12
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nuxt/devtools
-
fix: Inspect panel styles break when host page sets a custom html font-size (rem-based units) Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
-
feat: Nuxt devtools for AI Abiertoenhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
bug needs reproduction
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
Todos los issues de nuxt/devtools
Issues similares
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Crush Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
ElementsProject/cln-application#167 · 1 comentario · 1 reacción ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Quantco/pnpm-licenses#17 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100