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

Excessive memory consumption when handling large bundles without source maps

Đang mở Phù hợp với người mới
#344 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
javascript, node.js
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu trong source-map-support.js tại retrieveFile() và retrieveSourceMapURL(), sau đó lần theo đường dẫn bộ nhớ đệm của mapSourcePosition() được mô tả trong issue. Tái hiện việc tra cứu bằng một bundle lớn không có source map và xác minh rằng nội dung của nó không được giữ lại trong fileContentsCache sau lần tra cứu thất bại.

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

Mô tả

Environment:

  • Node.js with source-map-support
  • several large JavaScript bundles (5–7 MB each)
  • no source maps available for the bundles

Problem:

When an error is thrown in a large bundle, the source-map-support library unnecessarily retains the full file contents in memory. The file is loaded solely to check for a source map, but its contents are cached even after this one‑time operation. This results in excessive memory usage, especially problematic with multiple large bundles.

Steps to reproduce:

  1. An error is thrown in a bundle (e.g., index.js)
  2. Error.prepareStackTrace() is called
  3. The call chain proceeds as follows: wrapCallSite() → mapSourcePosition() → retrieveSourceMap("index.js") → retrieveSourceMapURL("index.js") → retrieveFile("index.js")
  4. The default retrieveFile handler loads the entire index.js file from disk and stores it in the fileContentsCache (source)
  5. retrieveSourceMapURL() fails to find a source map for the file
  6. mapSourcePosition() stores an empty source map in its internal cache (source)
  7. The full contents of index.js remain in the fileContentsCache indefinitely, consuming memory

Expected behavior:

File contents should be used only once to check for the presence of a source map, and then either not cached at all or discarded immediately after the check. There is no need to retain large bundle files in memory after this operation.

Actual behavior:

Large bundle files (5–7 MB) are retained in the fileContentsCache after the first error, leading to unnecessary increase in memory footprint.

Proposed solution:

Avoid caching when no source map is found: skip storing file contents in fileContentsCache if the source map lookup fails.

Ngôn ngữ chính
JavaScript
Star
2.2k
Fork
221
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 evanw/node-source-map-support

Tất cả issue của evanw/node-source-map-support

Issue tương tự

Thêm issue về JavaScript

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.