module: compile cache leaks temporary files when persistence fails
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
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp, javascript, nodejs
- Lĩnh vực
- backend, performance, testing
Hướng nghiên cứu
Bắt đầu tại src/compile_cache.cc, quanh các dòng 478-516, và chạy bản tái hiện RLIMIT_FSIZE được cung cấp để theo dõi việc xử lý tệp tạm thời qua các lỗi của write, close và rename. Thêm một bài kiểm thử hồi quy trên các nền tảng POSIX được hỗ trợ để xác minh rằng việc lưu trữ thất bại không để lại các tệp tạm thời có hậu tố ngẫu nhiên. Được xem là hoàn tất khi các lần ghi cache thất bại đóng các trình mô tả, xóa các đường dẫn tạm thời và duy trì việc cache thất bại một cách có kiểm soát.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
v24.15.0
Platform
Linux pike 7.0.0-29-generic #29-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 17 20:52:35 UTC 2026 x86_64 GNU/Linux
Subsystem
module compile cache
What steps will reproduce the bug?
This uses RLIMIT_FSIZE=0 to make mkstemp() succeed and the subsequent write fail. It requires no third-party dependencies or elevated privileges.
tmp="$(mktemp -d)"
mkdir -p "$tmp/cache"
printf '%s\n' 'module.exports = 42;' >"$tmp/fixture.cjs"
(
cd "$tmp"
ulimit -f 0
trap '' XFSZ
NODE_COMPILE_CACHE="$tmp/cache" node -e "require('./fixture.cjs')"
)
find "$tmp/cache" -type f -printf '%P %s bytes\n'
Example output:
v24.15.0-x64-cf738c9d-1000/712488c2.LuhsmB 0 bytes
v24.15.0-x64-cf738c9d-1000/8e9c99c2.hwlSas 0 bytes
v24.15.0-x64-cf738c9d-1000/9fb526e9.wPP9zO 0 bytes
The Node process exits with status 0.
How often does it reproduce? Is there a required condition?
Every run on the Linux system above. The required condition is that creation of the temporary cache file succeeds but a later write, close, or rename fails. EDQUOT, ENOSPC, and EFBIG are representative failure modes.
What is the expected behavior? Why is that the expected behavior?
The compile cache should continue to fail gracefully, but it should close the temporary file descriptor and unlink the temporary file whenever persistence does not complete. A failed cache write is disposable internal state and should not consume additional filesystem space or inodes.
What do you see instead?
Each failed entry leaves its random-suffix temporary file in the compile-cache directory. On the write-error path, its file descriptor also remains open until process teardown.
In a real EDQUOT incident, one Node process left 3,424 zero-byte compile-cache temporary files in one minute. This amplified a block-quota failure into substantial inode consumption.
Additional information
Current main creates the temporary file, then immediately continues on write, close, or rename errors without unlinking it:
The same control flow is present in v24.15.0.
A possible fix is an RAII cleanup guard established immediately after successful uv_fs_mkstemp() that:
- closes the descriptor if it is still open;
- unlinks the temporary path unless the rename succeeded;
- is disarmed only after successful rename;
- preserves the original persistence error.
A regression test can use the same RLIMIT_FSIZE technique on supported POSIX platforms and assert that no random-suffix temporary files remain.
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.4k
- Merge trung bình
- 4 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 279
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nodejs/node
-
doc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
build
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
feature request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
palladius/rails8-app-on-gcp#145 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotenvx/dotenv-vscode#139 ·
-
test-change-proposal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
web-platform-tests/interop#1455 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
corsairdev/corsair#1764 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100