Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Warn packagers about files with multiple identical paths in their package tarballs

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
領域
full-stack

調査の方向性

Start by reading the existing package main, stats, and code page data-fetching flows, then compare the proposed approaches with available package-tarball data providers. The issue names no files or tests and leaves the implementation strategy open; done means users can identify duplicate paths, see an accurate install size, and receive a warning for affected package versions.

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

説明

pending triage
Describe the feature

Today I discovered and fixed a bug in Bun's package publishing utilities:

We know that neither the TAR standard forbids nor does NPM itself reject such archives. I accidentally created such a package myself with Bun.

packed 1.0KB package.json
packed 8.19KB README.md
packed 247.73KB dist/minified/index.mjs
packed 247.73KB dist/minified/index.mjs

Total files: 4
v0.1.3 stats v0.1.3 code v0.1.4 stats v0.1.4 code
Claims package size: 504.7 kB; Claims install size: 504.7 kB
node_modules in fact has only ~250 kB,
because the copy overwrites itself
3 files visible Package size: 256.9 kB
Install size: 256.9 kB
the same 3 files visible

Packages created by bun pack/publish, as well as other package publishers, might be affected because there are no upstream guardrails. Bun users will still be affected for some time before either my PR or its modified version lands. Given the ratio of open/closed PRs on Bun's repo (5k/16k), I doubt it will happen any time soon.

I haven't gathered enough data yet to estimate how many packages with the same problem exist.

This feature request consists of essentially 3 things:

  1. Show a user on a main page a warning that the package is silently corrupted and unnecessarily bloated and should be republished properly.
  2. Make the stats page report the actual package install size, and not blindly trust the size reported by NPM. And maybe show both numbers: on disk vs. the data to be fetched.
  3. Make the code page highlight the paths that seem duplicated, similarly to how https://github.com/npmx-dev/npmx.dev/pull/2714 does it. I don't recall the exact implementation or how exactly the data is fetched. It only shows a single open file and a list of paths. I doubt you would fetch the whole package immediately just for that. And depending on whether the upstream data provider of the list of paths dedupes them or not, it might also be very easily implementable.

This would require some implementation, and I spent some time thinking about potential ways to do that.

Create a stateful backend service.

Doesn't store the actual packages. Doesn't even need to store them midflight because you only operate on the streamed metadata parts, discarding the contents. All it needs is essentially just file paths to identify if some would overwrite itself.

Variations:

  1. Process replication stream

    Variations:

    • can always be running, listening for the stream of changes
    • can wake up on CRON and process in batches the latest updates
    • Not sure if possible to deploy as an NPM-triggered lambda (but there are ways to launch on schedule). Even if NPM exposes a webhook like that, does it guarantee a stable order of events to drastically reduce storage needed, and is it replayable?

    Pros:

    • Compact storage. Only needs to store quite a small (I assume) set of [scope],package,version values (and can be stored efficiently via a trie, via a small normalized SQLite DB, via a plain JSON file, maybe even via atproto lol; anyway, a bit hard to estimate right now) and the latest processed replication pointer
    • durable because can just continue pulling new work after restarts, crashes, OOMs, whatever from the latest recorded replication pointer
    • rate limits don't usually apply to this approach, and you can pull data at whatever rate the internet connection allows

    Cons:

    • takes one big prefil. A price paid once (depending on the network speed, might take between a few hours and a full day)
    • processes, and rarely stores the scope+package+versions that might not ever be seen by npmx users. Given how small I assume the number of these broken packages is out there, it might not be a problem at all.
  2. Process packages on demand as they're requested via the web. The npmx visitors are the automatic trigger. I assume the set of affected packages is small and can be stored entirely without eviction.

    Variations:

    • Bug-less majority of packages is stored
      • Entirely to avoid ever refetching and recomputing. My estimation for this whole thing is about 500Mb-1Gb of data under the condition that NPMX users (scrapers/bots) will visit every single package and version that exist on NPM.
      • As a small-enough subset in a cache for popular pages with whatever eviction strategy
    • Deployment
      • Lives directly inside the server
      • A lambda that's triggered by either the npmx backend or as a separate second request from a browser

    Pros:

    • If we pretend that scrapers don't exist, you need to store only a subset of packages smaller by the same degree that NPMX's web UI traffic is smaller than NPM's.

    Cons:

    • A potential to store much more data than needed, because you also need to store whatever subset of packages NOT affected by the bug, to then avoid refetching it from NPM to not waste the server's bandwidth.
    • Might face NPM's rate limits

Pros:

  • the work is done globally once per package version published/first-viewed
  • no additional insane load on NPM
  • isn't really computationally expensive, and isn't very bandwidth-intensive
  • allows for static site generation. Can even be implemented nicely via something like a Suspense boundary, if Vue has something like this. The warning is tied to the version and will never change can be baked in
Do it client-side

Every time a user opens a page, the actual package tarball starts loading asynchronously after most of the page resources are fetched.

Variations

  • Cache isn't stored
  • Cache stored
    • in IndexedDB
    • in OPFS -- a possibility to choose a much more efficient format, but anyway I don't assume a single person to visit so many NPMX pages that it would ever become a problem

Pros

  • No additional load on NPMX
  • No need for a backend and storage to deploy and maintain by the NPMX team

Cons

  • Ugly
  • Wastes too much of the world's resources. On phones and metered connections, it has the potential to load VERY big packages that weigh like hundreds of megabytes and be quite costly, especially without a cache, just to get a simple boolean flag at the end of the operation.
  • The same work is done multiple times across the globe
  • I know NPM handles Billions of package downloads a day, but why would you still choose to hammer the non-profit that serves requests free of charge?...
  • Also has to store not only the list of packages that are affected by the bug, but also the ones that aren't. Essentially logging and storing purely client-side a list of packages and versions the user has ever visited.
Find whoever solved this problem already and reports THE ACTUAL install size that accounts for files overwriting each other

Something that actually analyses the tarball's content instead of trusting the misreported field inside the package's metadata. I have no idea if anything like this exists, but I think this would probably be the best option: finding some correct data provider.

Additional information
  • Would you be willing to help implement this feature?
Final checks

(even though this is a bunch of text, it's created and typed entirely by me)

主要言語
TypeScript
スター
3.6k
フォーク
533
平均マージ
4日 13時間
マージ済み PR(30日)
37

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

npmx-dev/npmx.dev のほかの issue

npmx-dev/npmx.dev の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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