Skip to content

feat: suggest proxy-aware retry command when network fails - #1387

Merged
danielroe merged 6 commits into
mainfrom
fix/network-resilience
Jul 25, 2026
Merged

feat: suggest proxy-aware retry command when network fails#1387
danielroe merged 6 commits into
mainfrom
fix/network-resilience

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolves #288
resolves #853

closes #419
closes #1089

📚 Description

a lot of issues we face are due to proxy issues with network requests

this PR improves the errors we show in these cases, and give people updated commands to run that will resolve the issue using node's builtin NODE_USE_ENV_PROXY

@codspeed-hq

codspeed-hq Bot commented Jul 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing fix/network-resilience (9032adf) with main (a94b9f5)

Open in CodSpeed

@pkg-pr-new

pkg-pr-new Bot commented Jul 25, 2026

Copy link
Copy Markdown
  • nuxt-cli-playground

    npm i https://pkg.pr.new/create-nuxt@1387
    
    npm i https://pkg.pr.new/nuxi@1387
    
    npm i https://pkg.pr.new/@nuxt/cli@1387
    

commit: 9032adf

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@danielroe, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f721cd8d-cd15-410a-8783-25cb1dfd7b5f

📥 Commits

Reviewing files that changed from the base of the PR and between d3280db and 9032adf.

📒 Files selected for processing (12)
  • packages/nuxt-cli/src/commands/init.ts
  • packages/nuxt-cli/src/commands/module/_utils.ts
  • packages/nuxt-cli/src/commands/module/add.ts
  • packages/nuxt-cli/src/commands/module/remove.ts
  • packages/nuxt-cli/src/commands/module/search.ts
  • packages/nuxt-cli/src/dev/binaries.ts
  • packages/nuxt-cli/src/main.ts
  • packages/nuxt-cli/src/utils/network.ts
  • packages/nuxt-cli/src/utils/starter-templates.ts
  • packages/nuxt-cli/test/unit/commands/network-failures.spec.ts
  • packages/nuxt-cli/test/unit/utils/network.spec.ts
  • packages/nuxt-cli/test/unit/utils/starter-templates.spec.ts
📝 Walkthrough

Walkthrough

Adds centralized proxy support and network error utilities to the Nuxt CLI, including error classification, formatted diagnostics, proxy hints, and retry command generation. CLI bootstrap now configures proxy propagation for child processes. Module, binary download, template initialization, nightly version, and npm dependency requests use structured network error reporting. Template and module API endpoints are centralized, the template request timeout increases to 5000 ms, and comprehensive unit tests cover the new utilities.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address the linked goals by improving init failures, adding proxy support, and better handling module requests behind corporate proxies [#288, #853, #419, #1089].
Out of Scope Changes check ✅ Passed The changes stay focused on network/proxy diagnostics, retry guidance, and related CLI commands, with no obvious unrelated additions.
Title check ✅ Passed The title clearly matches the main change: proxy-aware retry guidance for network failures.
Description check ✅ Passed The description is directly related to the PR, describing proxy-related network errors and NODE_USE_ENV_PROXY retry guidance.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/network-resilience

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/nuxt-cli/test/unit/utils/network.spec.ts (1)

63-72: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Silent early-return skips mask missing coverage.

Both reports the current process as proxy-aware when launched with the flag (Lines 63-66) and stays quiet when the proxy is already in use (Lines 162-164) silently return with zero assertions when !supportsEnvProxy(), rather than using an explicit skip (e.g. it.skipIf/test.skipIf). On a Node runtime where supportsEnvProxy() under- or over-detects support (see the related comment on network.ts), these tests would report green while exercising nothing, hiding exactly that kind of regression.

♻️ Suggested fix using Vitest's conditional skip
-  it('reports the current process as proxy-aware when launched with the flag', () => {
-    if (!supportsEnvProxy()) {
-      return
-    }
+  it.skipIf(!supportsEnvProxy())('reports the current process as proxy-aware when launched with the flag', () => {
     expect(isEnvProxyActive({ NODE_USE_ENV_PROXY: '1' }, [])).toBe(true)

Also applies to: 161-168

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nuxt-cli/test/unit/utils/network.spec.ts` around lines 63 - 72,
Replace the silent supportsEnvProxy() early returns in the tests “reports the
current process as proxy-aware when launched with the flag” and “stays quiet
when the proxy is already in use” with Vitest’s explicit conditional skip
mechanism, such as it.skipIf or test.skipIf. Preserve the existing assertions
and test behavior when proxy support is available.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/nuxt-cli/src/commands/init.ts`:
- Line 595: Move the fetchModules() promise creation inside the wantsUserModules
opt-in branch so the modules request is deferred until after confirmation.
Preserve the existing handling for opted-in users while ensuring declining the
prompt never invokes fetchModules() or its failure warning.

In `@packages/nuxt-cli/src/commands/module/add.ts`:
- Line 351: Replace description-only network warnings with proxy-aware
logNetworkError handling for recoverable failures. Update
packages/nuxt-cli/src/commands/module/add.ts lines 351-351,
packages/nuxt-cli/src/commands/module/remove.ts lines 71-71,
packages/nuxt-cli/src/dev/binaries.ts lines 159-159, and
packages/nuxt-cli/src/commands/init.ts lines 596-597 and 717-717, preserving
each existing failure context while emitting NODE_USE_ENV_PROXY retry guidance.

---

Nitpick comments:
In `@packages/nuxt-cli/test/unit/utils/network.spec.ts`:
- Around line 63-72: Replace the silent supportsEnvProxy() early returns in the
tests “reports the current process as proxy-aware when launched with the flag”
and “stays quiet when the proxy is already in use” with Vitest’s explicit
conditional skip mechanism, such as it.skipIf or test.skipIf. Preserve the
existing assertions and test behavior when proxy support is available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e369c0e8-3ac0-4cd8-a4d3-58b5315c8019

📥 Commits

Reviewing files that changed from the base of the PR and between f9af294 and 65ef878.

📒 Files selected for processing (10)
  • packages/nuxt-cli/src/commands/init.ts
  • packages/nuxt-cli/src/commands/module/_utils.ts
  • packages/nuxt-cli/src/commands/module/add.ts
  • packages/nuxt-cli/src/commands/module/remove.ts
  • packages/nuxt-cli/src/commands/module/search.ts
  • packages/nuxt-cli/src/dev/binaries.ts
  • packages/nuxt-cli/src/main.ts
  • packages/nuxt-cli/src/utils/network.ts
  • packages/nuxt-cli/src/utils/starter-templates.ts
  • packages/nuxt-cli/test/unit/utils/network.spec.ts

// ...or offer to browse and install modules (if not offline nor non-interactive)
else if (!ctx.args.offline && !ctx.args.preferOffline && !isNonInteractive) {
const modulesPromise = fetchModules()
const modulesPromise = fetchModules().catch((err) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Defer the modules request until the user opts in.

fetchModules() starts before the confirmation prompt, so declining module browsing still performs the request and can now emit a warning on failure. Create the promise only after wantsUserModules is true.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nuxt-cli/src/commands/init.ts` at line 595, Move the fetchModules()
promise creation inside the wantsUserModules opt-in branch so the modules
request is deferred until after confirmation. Preserve the existing handling for
opted-in users while ensuring declining the prompt never invokes fetchModules()
or its failure warning.

Comment thread packages/nuxt-cli/src/commands/module/add.ts Outdated
@danielroe
danielroe force-pushed the fix/network-resilience branch from d3280db to 53e6a29 Compare July 25, 2026 14:30
Comment thread packages/nuxt-cli/test/unit/utils/starter-templates.spec.ts Fixed
@danielroe
danielroe merged commit b0f9619 into main Jul 25, 2026
19 checks passed
@danielroe
danielroe deleted the fix/network-resilience branch July 25, 2026 15:35
This was referenced Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants