Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

fix: devtools is causing a severe memory leak

Đang mở
#761 29 bình luận 21 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
44/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
node.js, nuxt, typescript

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện memory leak với chuỗi lệnh nuxi init và npm run dev được cung cấp trên Windows với Node v22+, sau đó so sánh các lần chạy khi devtools được bật và tắt. Kiểm tra các snapshot xung quanh unstorage/readdirp, readable-stream và defineNuxtSchema, bao gồm cả lần khởi động lại do nuxt.config.ts kích hoạt; được xem là hoàn tất khi việc khởi động máy chủ phát triển lặp lại không còn cho thấy mức tăng bộ nhớ không giới hạn hoặc mức sử dụng CPU bất thường.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
🐛 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 }
Image

devtools: { enabled: false}
Image

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:

  1. npx nuxi dev --inspect with devtools disabled
  2. Open Chrome and go to chrome://inspect and inspect the Node project
  3. Let it run 5 minutes, collect garbage and take another snapshot (Snapshot 1, control)
  4. Edit nuxt.config.ts and enable devtools, let it restart with HMR
  5. Let it run 10 minutes, then collect garbage and take another snapshot (Snapshot 2)
  6. 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)
Image
Image
Image
Image
Image
Image

Full reproduction

Since I don't think stackblitz is going to show this issue:

  1. npx nuxi init@latest project
  2. cd project
  3. npm run dev
  4. Quit the process and re-run npm run dev
  5. Observe memory leak
  6. npx nuxi devtools disable
  7. npm run dev
  8. 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',
})
Ngôn ngữ chính
TypeScript
Star
3.3k
Fork
214
Merge trung bình
19 giờ 45 phút
Pull request đã merge (30 ngày)
12

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nuxt/devtools

Tất cả issue của nuxt/devtools

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.