Dev.to Security 🔐 Cybersecurity 👁 2 📖 5 min read

One upgrade commit took our lockfile from 1,093 packages to 1,062, and three lines of pnpm config explain why

Yesterday I upgraded 29 dependencies of Nakodo in one commit. The commit touches three files: package.json (58 lines), pnpm-lock.yaml (4,656 lines) and pnpm-workspace.yaml (14 lines). The diffstat says 2,195 lines added

Yesterday I upgraded 29 dependencies of Nakodo in one commit. The commit touches three files: package.json (58 lines), pnpm-lock.yaml (4,656 lines) and pnpm-workspace.yaml (14 lines). The diffstat says 2,195 lines added and 2,533 removed, so the repository got smaller by doing an upgrade. This post is about why, because the answer is in the smallest of the three files.

What went in

Next went from 16.3.7 to 16.4.6, React and React DOM from 19.2.8 to 19.3.1, Trigger.dev from 4.7.2 to 4.8.10, openai from 7.25.0 to 7.65.0, lucide-react from 1.49.0 to 1.84.0. No major version moved anywhere. Everything else is a minor or a patch.

After it, pnpm test reports 732 tests, 732 pass, in 1.8 seconds of test time (2.4 seconds on the wall clock, including tsx starting). pnpm typecheck is clean in 4.4 seconds. I mention the numbers because an upgrade you cannot check in seven seconds is an upgrade you will put off.

What came out

The lockfile has a packages: section with one entry per name and version. I pulled it from the commit before and the commit after:

git show HEAD~1:pnpm-lock.yaml \
  | awk '/^packages:/{p=1;next}/^snapshots:/{p=0}p&&/^  [^ ]/' | sort > old.txt
git show HEAD:pnpm-lock.yaml \
  | awk '/^packages:/{p=1;next}/^snapshots:/{p=0}p&&/^  [^ ]/' | sort > new.txt
comm -23 old.txt new.txt | wc -l   # 327 entries gone
comm -13 old.txt new.txt | wc -l   # 296 entries new

1,093 entries before, 1,062 after. 327 gone, 296 arrived, net minus 31. Most of the churn is the same package at a newer version, which counts as one gone and one new. The net minus 31 is the interesting part, and some of it is deliberate.

Three lines that collapse versions

pnpm-workspace.yaml gained this block:

overrides:
  'zod@<4.6.6': ^4.6.7
  'source-map-js@<1.2.2': ^1.2.4
  'effect@<3.22.1': ^3.22.5

Each key is a package and a range that is too old to keep. Each value is where anything asking for that range goes instead. These are not direct dependencies in two of the three cases. They are things that Trigger.dev, shadcn, Tailwind and Next each pull in, each with its own idea of an acceptable version.

Here is what the lockfile held for those three names before and after:

package before after
zod 3.25.76, 4.5.4, 4.6.5 4.6.7
effect 3.21.0, 3.22.2 3.22.5
source-map-js 1.2.1 1.2.4

zod is the one that earns its keep. Three copies of it were installed, one of them a whole major version behind, and I only wrote one of those. pnpm why zod now prints a single [email protected] with the paths hanging off it (shadcn, trigger.dev, @trigger.dev/core, eslint-plugin-react-hooks, openai, and our own package.json). You can run it yourself in any pnpm project and see which of your dependencies are the reason a name appears more than once.

Overrides are blunt. They apply to everything, including packages that asked for the old range on purpose. The upside here is that 732 tests and a type check both pass with it on. If one of them stopped passing, the override would be the first thing I removed, not the last.

The package manager decides who may run code

The first lines of the same file are older, from before this commit:

allowBuilds:
  '@depot/cli': true
  core-js: false
  esbuild: true
  sharp: false
  unrs-resolver: false

pnpm 11 does not run a dependency's install scripts unless you list it. The file's history shows when each line arrived. sharp: false and unrs-resolver: false were in the very first commit, written by create-next-app. esbuild: true came with the first real feature on 1 October, @depot/cli: true with the Trigger.dev work on 3 October, and core-js: false with the analytics work on 17 October. Each entry is a decision someone made once, at the moment a new package asked for permission, and the answer is now in version control.

That is 1,062 packages and five lines that decide which of them may execute anything on a machine at install time.

The waiting period, and the five exceptions to it

The next block explains why the Trigger.dev bump needed an entry at all:

minimumReleaseAgeExclude:
  - '@trigger.dev/[email protected]'
  - '@trigger.dev/[email protected]'
  - '@trigger.dev/[email protected]'
  - '@trigger.dev/[email protected]'
  - [email protected]

The setting it modifies is not in the file. pnpm's workspace state records "minimumReleaseAge": 1440 for this project. That is minutes, so pnpm refuses to install any version published less than 24 hours ago. A compromised release is usually noticed and pulled within hours, and a one day delay means you are rarely the person who finds out first.

The five exclusions exist because Trigger.dev's CLI, SDK and build packages are released together and I want them on the same version. When one of them is newer than a day, the choice is to wait or to name it. We name the five, by exact version. The exclusion does not cover a future 4.8.11, so it expires on its own the next time I bump them.

The exclusion block arrived on 3 October with the first Trigger.dev work, pinned to 4.7.2, and this commit is its first bump. That is the real cost of the exception: five lines to edit by hand each time. The overrides block is new in this commit.

How many of them are ours to worry about

pnpm list --depth Infinity --parseable counts 1,065 paths on disk. With --prod it counts 511. So about half of what is installed ships to the server that handles requests, and the other half is the compiler, the linter, the type checker and the CLI. When one of the three overridden names turns out to have a security note, that split is the first question to ask, and pnpm why answers it in one command.

What I would change

  • The override block has no comment explaining why each entry exists. Today the reason lives in the commit message. A # duplicate of a major we do not use line next to zod@<4.6.6 would survive a squash.
  • There is no check that an override is still doing something. Once every dependent has moved past the old range, the line is dead weight. A script that runs pnpm why for each key and fails on a single version would find the dead ones.
  • The two Trigger.dev bump steps should be one: a pnpm trigger:bump script that edits the five lines and the three package.json versions together, so they cannot drift.

If you want to see what the app does with all of this, the pages that name our outside providers are the privacy notice and how it works. Neither mentions pnpm, which is the point of having a package manager do its job without an audience.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.