Repository navigation
Description
pnpm version
12.6.0
Which area(s) of pnpm are affected?
Hooks, Dependencies resolver, Lockfile
Reproduction steps
Two packages, probe-a@1.0.0 depending on probe-b@1.0.0, each packed to a tarball under vendor/. The root manifest depends only on probe-a. A .pnpmfile.cjs resolves both through a resolvers hook that returns a custom resolution type and no manifest, and fetches both through a fetchers hook:
const { createHash } = require('node:crypto')
const { readFileSync } = require('node:fs')
const P = { 'probe-a': 'probe-a.tgz', 'probe-b': 'probe-b.tgz' }
const iOf = n => 'sha512-' + createHash('sha512').update(readFileSync(__dirname + '/vendor/' + n)).digest('base64')
module.exports = {
resolvers: [{
canResolve: w => P[w.alias] !== undefined,
resolve: w => ({
id: w.alias + '@1.0.0',
// no `manifest`: it is optional on ResolveResult
resolution: { type: 'custom:probe', name: w.alias, version: '1.0.0', integrity: iOf(P[w.alias]) },
}),
}],
fetchers: [{
canFetch: (id, r) => r.type === 'custom:probe',
fetch: (cafs, r, opts, f) =>
f.localTarball(cafs, { tarball: 'file:./vendor/' + P[r.name], integrity: iOf(P[r.name]) }, opts),
}],
}Run pnpm install, then check whether the dependency was linked:
$ ls node_modules/.pnpm/probe-a@1.0.0/node_modules/
probe-a
probe-b is missing.
Describe the Bug
manifest is optional on the ResolveResult a resolvers hook returns. When it is omitted, pnpm reads the package's own dependencies out of the fetched tarball. That recovery does not happen when the resolution carries a custom type, so the package installs with none of its dependencies, silently, exit 0.
This is the remaining gap in the fix chain for #15000. #15013 (12.5.0) made pnpm read the manifest out of a fetched remote tarball, and #15016 (12.6.0) extended that to local and git-hosted tarballs. Both key off the resolution kind, so a resolution routed to a custom fetchers hook is still excluded.
The discriminator is the resolution type, not the tarball location. Adding a tarball: file:... field to the custom-typed resolution changes nothing. Results on 12.6.0, asking whether probe-b gets linked under probe-a:
| what the resolver returns | dependency installed |
|---|---|
custom type, no manifest |
no |
custom type and a tarball field, no manifest |
no |
plain file: tarball resolution, no manifest |
yes |
Lockfile for the failing case:
packages:
probe-a@1.0.0:
resolution: {name: probe-a, version: 1.0.0, integrity: sha512-sRGp/4W..., type: custom:probe}
snapshots:
probe-a@1.0.0: {}The same run with a plain file: tarball resolution and no manifest records the dependency:
snapshots:
probe-a@1.0.0:
dependencies:
probe-b: probe-b@1.0.0
probe-b@1.0.0: {}Why this is not only a resolver-authoring mistake
Returning manifest from resolve fixes this for the resolver author, and switching to a plain tarball resolution reaches the already-fixed path. Neither is always available.
A custom resolution type exists so that the resolution records no location. That is what keeps the lockfile portable: the same lockfile resolves against different sources on different machines, and the custom fetcher decides where the bytes come from at fetch time. Rewriting the resolution as tarball: file:/abs/path bakes a machine-specific path into the lockfile, defeating the reason the custom fetcher exists.
Impact
The failure is silent and leaves an install that looks healthy. The install prints Packages: +1 and Done with no warning, and resolved 1 is the only hint that a dependency went missing. An entire dependency subtree is absent from node_modules, so the first symptom is a module-not-found error at runtime, far from the cause.
The empty snapshot is written to the lockfile, so the missing dependencies survive commit and propagate to every later install. A --frozen-lockfile install also succeeds with exit 0 and the dependency still missing, so CI does not flag it.
Root cause
The archive read that recovers a missing manifest is gated on the resolution being a tarball, in pnpm/crates/package-manager/src/prefetching_resolver/archive_read.rs:
fn of(result: &ResolveResult) -> Option<(Self, &pnpm_lockfile::TarballResolution)> {
let LockfileResolution::Tarball(tarball) = &result.resolution else {
return None;
};A resolution with a type field deserializes to LockfileResolution::Custom, so it returns None here and populate_missing_tarball_metadata treats that as nothing missing. resolve_wanted_cached then synthesizes a placeholder manifest, {"name": <alias>, "version": "0.0.0"}, in resolving-deps-resolver/src/resolve_dependency_tree/walk/workspace_resolution.rs. The dependency walk reads that placeholder, finds no dependencies, and reports no error, which is why the install looks healthy.
The bytes are available at that point. The fetch hook has already run and the tarball is in the content-addressable store. The manifest is not unavailable, it is not consulted.
One note for whoever picks this up: widening the gate is not sufficient on its own. resolve_archive_metadata re-encodes the resolution with the fetched integrity in deps-restorer/src/custom_fetcher/metadata.rs, and decode_resolution rejects any resolution whose type is present and not binary, so a custom-typed resolution reaching it fails with ERR_PNPM_TARBALL_INTEGRITY. Custom resolutions need the verbatim-preservation treatment that commit-addressed resolutions already get, since a custom resolution's integrity scheme belongs to the fetcher rather than the built-in verifier.
This affects pnpm 12 only. pnpm 11 reads the bundled manifest whenever manifest is absent, independent of resolution type, in installing/package-requester/src/packageRequester.ts.
Suggested fix
Apply the manifest-from-tarball recovery to resolutions handled by a custom fetchers hook, keying off "the resolver returned no manifest" rather than off the resolution kind.
Failing that, warning when a resolver returns no manifest and pnpm cannot recover one would at least turn a silent wrong install into a diagnosable one.
Expected Behavior
A resolver may omit the optional manifest, and pnpm recovers the package's dependencies from the fetched tarball's bundled package.json, as it already does for tarball resolutions.
Which Node.js version are you using?
24.21.0
Which operating systems have you used?
macOS
Written by an agent (Claude Code, claude-opus-5).
Activity
fix(package-manager): recover a missing manifest for a custom resolut…
fix(package-manager): recover a missing manifest for a custom resolut…
fix(package-manager): recover a missing manifest for a custom resolut…
chore(deps): update pnpm to v12.7.0