fix: try not to make network requests with prefer offline - #10334
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the behavior of the preferOffline mode to prevent unnecessary network requests when cached metadata exists. Previously, preferOffline would still attempt network requests even when valid cached data was available.
Key Changes:
- Modified the condition to return early when cached metadata is found in
preferOfflinemode - Moved the error throwing logic to only apply in
offlinemode, notpreferOfflinemode - Added comprehensive test coverage to verify no network requests occur with
preferOfflinewhen cache exists
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| resolving/npm-resolver/src/pickPackage.ts | Updated logic to return cached metadata immediately in preferOffline mode and only throw errors in strict offline mode |
| resolving/npm-resolver/test/index.ts | Added test case verifying that preferOffline uses cached metadata without making network requests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
samchungy
force-pushed
the
try-not-tomake-network-requests
branch
from
December 19, 2025 07:32
54d297b to
1b75e00
Compare
samchungy
commented
Dec 20, 2025
zkochan
approved these changes
Dec 21, 2025
zkochan
pushed a commit
that referenced
this pull request
Dec 23, 2025
dadezzz
pushed a commit
to dadezzz/university_notes
that referenced
this pull request
Dec 29, 2025
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [pnpm](https://pnpm.io) ([source](https://github.com/pnpm/pnpm/tree/HEAD/pnpm)) | [`10.26.1` → `10.26.2`](https://renovatebot.com/diffs/npm/pnpm/10.26.1/10.26.2) |  |  | --- ### Release Notes <details> <summary>pnpm/pnpm (pnpm)</summary> ### [`v10.26.2`](https://github.com/pnpm/pnpm/releases/tag/v10.26.2): pnpm 10.26.2 [Compare Source](pnpm/pnpm@v10.26.1...v10.26.2) #### Patch Changes - Improve error message when a package version exists but does not meet the `minimumReleaseAge` constraint. The error now clearly states that the version exists and shows a human-readable time since release (e.g., "released 6 hours ago") [#​10307](pnpm/pnpm#10307). - Fix installation of Git dependencies using annotated tags [#​10335](pnpm/pnpm#10335). Previously, pnpm would store the annotated tag object's SHA in the lockfile instead of the actual commit SHA. This caused `ERR_PNPM_GIT_CHECKOUT_FAILED` errors because the checked-out commit hash didn't match the stored tag object hash. - Binaries of runtime engines (Node.js, Deno, Bun) are written to `node_modules/.bin` before lifecycle scripts (install, postinstall, prepare) are executed [#​10244](pnpm/pnpm#10244). - Try to avoid making network calls with preferOffline [#​10334](pnpm/pnpm#10334). #### Platinum Sponsors <table> <tbody> <tr> <td align="center" valign="middle"> <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://bit.dev/?utm_source=pnpm&utm_medium=release_notes" rel="nofollow">https://bit.dev/?utm_source=pnpm&utm_medium=release_notes" target="_blank"><img src="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://pnpm.io/img/users/bit.svg" rel="nofollow">https://pnpm.io/img/users/bit.svg" width="80" alt="Bit"></a> </td> </tr> </tbody> </table> #### Gold Sponsors <table> <tbody> <tr> <td align="center" valign="middle"> <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://discord.com/?utm_source=pnpm&utm_medium=release_notes" rel="nofollow">https://discord.com/?utm_source=pnpm&utm_medium=release_notes" target="_blank"> <picture> <source media="(prefers-color-scheme: light)" srcset="https://pnpm.io/img/users/discord.svg" /> <source media="(prefers-color-scheme: dark)" srcset="https://pnpm.io/img/users/discord_light.svg" /> <img src="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://pnpm.io/img/users/discord.svg" rel="nofollow">https://pnpm.io/img/users/discord.svg" width="220" alt="Discord" /> </picture> </a> </td> <td align="center" valign="middle"> <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://coderabbit.ai/?utm_source=pnpm&utm_medium=release_notes" rel="nofollow">https://coderabbit.ai/?utm_source=pnpm&utm_medium=release_notes" target="_blank"> <picture> <source media="(prefers-color-scheme: light)" srcset="https://pnpm.io/img/users/coderabbit.svg" /> <source media="(prefers-color-scheme: dark)" srcset="https://pnpm.io/img/users/coderabbit_light.svg" /> <img src="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://pnpm.io/img/users/coderabbit.svg" rel="nofollow">https://pnpm.io/img/users/coderabbit.svg" width="220" alt="CodeRabbit" /> </picture> </a> </td> <td align="center" valign="middle"> <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://workleap.com/?utm_source=pnpm&utm_medium=release_notes" rel="nofollow">https://workleap.com/?utm_source=pnpm&utm_medium=release_notes" target="_blank"> <picture> <source media="(prefers-color-scheme: light)" srcset="https://pnpm.io/img/users/workleap.svg" /> <source media="(prefers-color-scheme: dark)" srcset="https://pnpm.io/img/users/workleap_light.svg" /> <img src="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://pnpm.io/img/users/workleap.svg" rel="nofollow">https://pnpm.io/img/users/workleap.svg" width="190" alt="Workleap" /> </picture> </a> </td> </tr> <tr> <td align="center" valign="middle"> <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://stackblitz.com/?utm_source=pnpm&utm_medium=release_notes" rel="nofollow">https://stackblitz.com/?utm_source=pnpm&utm_medium=release_notes" target="_blank"> <picture> <source media="(prefers-color-scheme: light)" srcset="https://pnpm.io/img/users/stackblitz.svg" /> <source media="(prefers-color-scheme: dark)" srcset="https://pnpm.io/img/users/stackblitz_light.svg" /> <img src="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://pnpm.io/img/users/stackblitz.svg" rel="nofollow">https://pnpm.io/img/users/stackblitz.svg" width="190" alt="Stackblitz" /> </picture> </a> </td> <td align="center" valign="middle"> <a href="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://vite.dev/?utm_source=pnpm&utm_medium=release_notes" rel="nofollow">https://vite.dev/?utm_source=pnpm&utm_medium=release_notes" target="_blank"> <img src="proxy.php?url=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F%3Ca+href%3D"https://pnpm.io/img/users/vitejs.svg" rel="nofollow">https://pnpm.io/img/users/vitejs.svg" width="42" alt="Vite"> </a> </td> </tr> </tbody> </table> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi42NC4xIiwidXBkYXRlZEluVmVyIjoiNDIuNjQuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: Renovate Bot <renovate@zarantonello.dev> Co-committed-by: Renovate Bot <renovate@zarantonello.dev>
zkochan
added a commit
that referenced
this pull request
Jan 12, 2026
zkochan
added a commit
that referenced
this pull request
Jan 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed when using
--prefer-offlinepnpm would still attempt to make network calls despite already having the package within the cache.This stops pnpm from making some network calls when the package already exists within the cache when using --prefer-offline.