nodejs / nodejs/node

`require.cache` is `undefined` in SEA

オープン
#49,163 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

single-executable stale
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

main.js での再現と sea-config.json を使用した SEA セットアップから始め、通常の Node プロセスと生成された実行可能ファイルでの require.cache の動作を比較します。Node.js モジュールのドキュメントと SEA 関連のランタイムエントリポイントを読みます。再現した SEA ケースで require.cache がオブジェクトになり、Fastify pluginUtils のユースケースを壊さなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, nodejs
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。