Skip to content

pnpm run re-resolves the lockfile, poisoning the Docker test context #26

Closed

Description

@stuffbucket

What happens

Any pnpm run <script> in this workspace rewrites pnpm-lock.yaml before the script body executes, adding ~1610 rotating ms-feed-N.pkgs.visualstudio.com tarball URLs to entries that were recorded host-free.

Reproduced on both branches:

$ node scripts/strip-lockfile-hosts.mjs   # -> 0 tarball entries
$ pnpm run verify:workspace >/dev/null
$ grep -c 'tarball:' pnpm-lock.yaml
1610

Main reproduces identically at 1602 entries (it has fewer packages). A pnpm install --frozen-lockfile immediately beforehand does not prevent it.

Why it now matters

Previously this was invisible local churn — you stripped before committing and moved on. With the mountless Docker harness (#25) it becomes a hard failure:

  1. pnpm test is itself a pnpm run, so it poisons the lockfile;
  2. docker build copies the working tree, carrying the poisoned lockfile into the context;
  3. the in-image pnpm install --frozen-lockfile runs the supply-chain policy check and rejects it with ERR_PNPM_TARBALL_URL_MISMATCH, ~1198 entries.

The image build fails before any test runs. pnpm test — documented in docs/testing-in-docker.md as "the only supported way to run the monorepo test graph" — cannot succeed on a warm checkout.

Workaround

Bypassing pnpm's script runner keeps the context clean and the full graph passes 15/15:

node scripts/strip-lockfile-hosts.mjs && node scripts/docker-test.mjs

Worth considering

  • Have docker-test.mjs build its context from git archive HEAD rather than the working tree — the committed lockfile is host-free by policy, and this also makes the harness independent of local dirt.
  • Or strip hosts into the build context as a wrapper step.

CI is green on main, so whatever triggers the re-resolution appears specific to a warm local store/metadata cache against the rotating 1ES shards. That difference is not currently understood.

Not investigated

  • which pnpm 11.17 mechanism re-resolves on pnpm run (no verifyDepsBeforeRun is configured);
  • why CI does not hit it, given the same pnpm version and registry.

Activity

  1. stuffbucket commented on Sep 2, 2026

    @stuffbucket
    OwnerAuthor

    pnpm exec does it too, so the stated workaround is narrower than the behaviour

    Hit this while working on the release pipeline. The title and the workaround both say pnpm run, but the trigger is not the run subcommand.

    Reproduced on a clean tree at 9a952c9:

    $ grep -c 'tarball:' pnpm-lock.yaml
    0
    $ pnpm exec turbo run typecheck lint --filter maximal-client
     Tasks:    7 successful, 7 total
    $ grep -c 'tarball:' pnpm-lock.yaml
    1610
    

    No install was asked for and no manifest changed — pnpm exec re-resolved and wrote the rotating ms-feed-N hosts back, exactly as pnpm run does. git checkout -- pnpm-lock.yaml restores it.

    Two consequences worth folding in:

    • The workaround "call the script directly with node" only covers pnpm run. Anything routed through pnpm that can touch the store appears to re-resolve, so pnpm exec turbo … needs the same treatment or the same guard.
    • It is easy to commit the damage without noticing, because the poisoned lockfile does not fail the run that caused it — it fails the next install, in whatever context that happens to be.

    For what it is worth, pnpm install --frozen-lockfile did not poison the file in the same session, so --frozen-lockfile still looks like the safe path.

    What I have been doing, which might be worth putting in the workaround section: capture grep -c 'tarball:' pnpm-lock.yaml before and after any pnpm invocation and git checkout -- pnpm-lock.yaml if it moved. That caught it here before it reached a commit.

  2. stuffbucket commented on Sep 7, 2026

    @stuffbucket
    OwnerAuthor

    Resolved by #73 and #77. pnpm-workspace.yaml now prevents pnpm run from performing an implicit install, and .pnpmfile.cjs strips rotating shard hosts whenever the lockfile is written. The full workspace check passes without changing pnpm-lock.yaml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions