nodejs / nodejs/node

`require.cache` is `undefined` in SEA

Đang mở
#49,163 9 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

single-executable stale
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)
272

Mô tả

Version

v20.4.0 v20.5.1 v20.3.0

Platform

Linux 5.15.90.1-microsoft-standard-WSL2

Subsystem

No response

What steps will reproduce the bug?
echo 'console.log(typeof require.cache)' > main.js
node main.js
echo '{ "main": "main.js", "output": "sea-prep.blob" }' > sea-config.json
node --experimental-sea-config sea-config.json
cp $(command -v node) hello
npx postject hello NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
./hello
How often does it reproduce? Is there a required condition?

Always reproducible

What is the expected behavior? Why is that the expected behavior?

require.cache should be an object as of https://nodejs.org/api/modules.html#requirecache

What do you see instead?

require.cache is undefined. Trying to index it or enumerate it with Object.entries will result in TypeError

Additional information

This is relevant for Fastify which uses cache to provide a printable name for a plugin (based on its file path). See https://github.com/fastify/fastify/blob/c235d2dc136a67c51095f188742c743d8cb32839/lib/pluginUtils.js#L27

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.

Hướng nghiên cứu

Bắt đầu với việc tái hiện trong main.js và thiết lập SEA bằng sea-config.json, sau đó so sánh hành vi của require.cache trong một tiến trình Node thông thường và trong tệp thực thi được tạo. Đọc tài liệu module của Node.js và các runtime entry point liên quan đến SEA; công việc được hoàn tất khi require.cache là một object trong trường hợp SEA được tái hiện mà không làm hỏng use case Fastify pluginUtils.

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

Đánh giá

Công nghệ
javascript, nodejs
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
52/100

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.