Skip to content

Commit 28ddf66

Browse files
committed
perf(installing): skip lockfile verification when delegating to pacquet
Pacquet's frozen-install path runs the same resolver-policy gate (port of `verifyLockfileResolutions`), so re-running on the pnpm side before delegating duplicates the work — and for `minimumReleaseAge` in strict mode each entry costs an HTTP probe. Gated narrowly: only skipped when `--frozen-lockfile` (or the CI `frozenLockfileIfExists` default against an existing lockfile) is in play. The optimistic `preferFrozenLockfile` path decides whether to delegate later, inside `tryFrozenInstall`, so verification still runs there.
1 parent 01d66a9 commit 28ddf66

1 file changed

Lines changed: 31 additions & 19 deletions

File tree

  • installing/deps-installer/src/install

installing/deps-installer/src/install/index.ts

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -362,25 +362,37 @@ export async function mutateModules (
362362
// resolver's own filters already cover fresh resolution. We run this
363363
// exactly once, right after the lockfile is loaded from disk, before any
364364
// path branches.
365-
const cacheActive = opts.cacheDir != null && opts.resolutionVerifiers.length > 0
366-
const wantedLockfilePath = cacheActive
367-
? path.resolve(ctx.lockfileDir, await getWantedLockfileName({
368-
useGitBranchLockfile: opts.useGitBranchLockfile,
369-
mergeGitBranchLockfiles: opts.mergeGitBranchLockfiles,
370-
}))
371-
: undefined
372-
try {
373-
await verifyLockfileResolutions(ctx.wantedLockfile, opts.resolutionVerifiers, {
374-
cacheDir: opts.cacheDir,
375-
lockfilePath: wantedLockfilePath,
376-
})
377-
} catch (err) {
378-
// verifyLockfileResolutions is the one throw site in this function
379-
// that's part of normal user-facing operation (a rejected lockfile);
380-
// other throws here are unexpected. Detach the reporter listener so
381-
// long-lived processes don't leak it on every rejected install.
382-
detachReporter()
383-
throw err
365+
//
366+
// Skipped when we already know pacquet will run the install: pacquet's
367+
// frozen-install path applies the same resolver-policy gate (port of
368+
// this function), so re-running here would duplicate the work. The
369+
// optimistic frozen-like path (`preferFrozenLockfile` + all projects
370+
// up-to-date) decides whether to delegate later, inside
371+
// `tryFrozenInstall`, so verification still runs there — the duplicate
372+
// is bounded to that narrow window.
373+
const willDelegateToPacquet = opts.configDependencies?.pacquet != null &&
374+
(opts.frozenLockfile === true || (opts.frozenLockfileIfExists === true && ctx.existsNonEmptyWantedLockfile))
375+
if (!willDelegateToPacquet) {
376+
const cacheActive = opts.cacheDir != null && opts.resolutionVerifiers.length > 0
377+
const wantedLockfilePath = cacheActive
378+
? path.resolve(ctx.lockfileDir, await getWantedLockfileName({
379+
useGitBranchLockfile: opts.useGitBranchLockfile,
380+
mergeGitBranchLockfiles: opts.mergeGitBranchLockfiles,
381+
}))
382+
: undefined
383+
try {
384+
await verifyLockfileResolutions(ctx.wantedLockfile, opts.resolutionVerifiers, {
385+
cacheDir: opts.cacheDir,
386+
lockfilePath: wantedLockfilePath,
387+
})
388+
} catch (err) {
389+
// verifyLockfileResolutions is the one throw site in this function
390+
// that's part of normal user-facing operation (a rejected lockfile);
391+
// other throws here are unexpected. Detach the reporter listener so
392+
// long-lived processes don't leak it on every rejected install.
393+
detachReporter()
394+
throw err
395+
}
384396
}
385397

386398
if (opts.hooks.preResolution) {

0 commit comments

Comments
 (0)