Skip to content

Conversation

@danielroe
Copy link
Member

🔗 Linked issue

resolves #32789

📚 Description

this bumps the timeout for vite-node fetches to 1 minute and allows configuring this interval

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Walkthrough

This change introduces a new optional viteNode configuration object within the vite property of the ConfigSchema interface. The viteNode object allows specification of four numeric properties: maxRetryAttempts, baseRetryDelay, maxRetryDelay, and requestTimeout, all related to retry and timeout behaviour. These properties are added to the ViteNodeServerOptions type and are passed through the ViteNodePlugin during server creation. In the runtime, the relevant constants for retry and timeout are now initialised from these configuration options, with defined fallback defaults.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eee55ea and df56143.

📒 Files selected for processing (3)
  • packages/schema/src/types/schema.ts (1 hunks)
  • packages/vite/src/runtime/vite-node-shared.mjs (1 hunks)
  • packages/vite/src/vite-node.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • packages/vite/src/vite-node.ts
  • packages/schema/src/types/schema.ts
🧠 Learnings (3)
📚 Learning: in nuxt, using `rolldownversion` (not `rollupversion`) is intentional when detecting if rolldown-vit...
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.

Applied to files:

  • packages/vite/src/vite-node.ts
  • packages/schema/src/types/schema.ts
📚 Learning: in `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distdir` are l...
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.

Applied to files:

  • packages/vite/src/vite-node.ts
📚 Learning: applies to **/*.{test,spec}.{ts,tsx,js,jsx} : write unit tests for core functionality using `vitest`...
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T16:46:07.446Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js,jsx} : Write unit tests for core functionality using `vitest`

Applied to files:

  • packages/schema/src/types/schema.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: build
  • GitHub Check: codeql (javascript-typescript)
  • GitHub Check: code
🔇 Additional comments (4)
packages/vite/src/vite-node.ts (2)

499-502: LGTM! Well-structured type definition additions.

The new optional properties for retry and timeout configuration are properly typed and documented with clear unit specifications.


193-196: LGTM! Proper configuration propagation.

The implementation correctly uses optional chaining to safely extract the viteNode configuration options and passes them through to the server options. This maintains backward compatibility while enabling the new timeout and retry configuration features.

packages/vite/src/runtime/vite-node-shared.mjs (1)

19-22: LGTM! Significant timeout improvement addresses the core issue.

The implementation correctly uses configurable values with sensible fallback defaults. The increase in default request timeout from 10 seconds to 60 seconds directly addresses issue #32789 where requests were timing out during module loading in Nuxt 4, particularly during HMR and project startup.

packages/schema/src/types/schema.ts (1)

1650-1660: LGTM! Schema extension properly defines the new configuration structure.

The schema correctly extends the vite configuration with the optional viteNode object containing the four timeout and retry properties. The intersection type approach maintains backward compatibility whilst clearly documenting the available configuration options with appropriate units.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/vite-node-options

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Walkthrough

The changes introduce new optional configuration properties—maxRetryAttempts, baseRetryDelay, maxRetryDelay, and requestTimeout—for the viteNode section within the vite configuration schema. These properties are added to the relevant TypeScript interfaces and types, allowing users to customise retry and timeout behaviour for Vite Node operations. The runtime logic in the Vite Node shared module is updated to use these configurable values with specified defaults, and the Vite Node server options are extended to include these new properties, sourced from the configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/vite-node-options

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/vite/src/runtime/vite-node-shared.mjs (1)

19-22: Validate and coerce env-supplied values to numbers

process.env.NUXT_VITE_NODE_OPTIONS is parsed from JSON, but users (or future tooling) might still inject string values.
Using the numeric operators later (Math.pow, comparisons) will coerce strings implicitly but hides invalid/NaN input and may break the exponential-back-off if e.g. "abc" is supplied.

Consider an explicit coercion + fallback:

-const MAX_RETRY_ATTEMPTS = viteNodeOptions.maxRetryAttempts ?? 5
-const BASE_RETRY_DELAY_MS = viteNodeOptions.baseRetryDelay ?? 100
-const MAX_RETRY_DELAY_MS = viteNodeOptions.maxRetryDelay ?? 2000
-const REQUEST_TIMEOUT_MS  = viteNodeOptions.requestTimeout  ?? 60_000
+const toNumber = (v, d) => Number.isFinite(+v) ? +v : d
+
+const MAX_RETRY_ATTEMPTS = toNumber(viteNodeOptions.maxRetryAttempts, 5)
+const BASE_RETRY_DELAY_MS = toNumber(viteNodeOptions.baseRetryDelay, 100)
+const MAX_RETRY_DELAY_MS = toNumber(viteNodeOptions.maxRetryDelay, 2000)
+const REQUEST_TIMEOUT_MS  = toNumber(viteNodeOptions.requestTimeout, 60_000)

This guards against accidental mis-configuration without impacting the happy path.

packages/vite/src/vite-node.ts (1)

193-197: Normalise config values to numbers before serialising

The four new options are forwarded verbatim from nuxt.options.vite.viteNode.
If a user sets them as strings in nuxt.config.ts (common when pulling from env vars), they are serialised unchanged and the runtime must then coerce them.

Doing the coercion once here avoids duplication and keeps vite-node-shared lean:

          maxRetryAttempts: Number(nuxt.options.vite.viteNode?.maxRetryAttempts) || undefined,
          baseRetryDelay:   Number(nuxt.options.vite.viteNode?.baseRetryDelay)   || undefined,
          maxRetryDelay:    Number(nuxt.options.vite.viteNode?.maxRetryDelay)    || undefined,
          requestTimeout:   Number(nuxt.options.vite.viteNode?.requestTimeout)   || undefined,

This keeps the JSON payload strictly numeric and protects against invalid input early.

packages/schema/src/types/schema.ts (1)

1650-1660: Minor: add default values / unit hints in the JSDoc

The new viteNode schema is great, but documenting defaults (5, 100 ms, 2000 ms, 60000 ms) and units makes schema.d.ts self-explanatory for consumers and IDE tooltips.

No code change required – only JSDoc refinement.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eee55ea and df56143.

📒 Files selected for processing (3)
  • packages/schema/src/types/schema.ts (1 hunks)
  • packages/vite/src/runtime/vite-node-shared.mjs (1 hunks)
  • packages/vite/src/vite-node.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • packages/schema/src/types/schema.ts
  • packages/vite/src/vite-node.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.
📚 Learning: in nuxt, using `rolldownversion` (not `rollupversion`) is intentional when detecting if rolldown-vit...
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.

Applied to files:

  • packages/schema/src/types/schema.ts
  • packages/vite/src/vite-node.ts
📚 Learning: applies to **/*.{test,spec}.{ts,tsx,js,jsx} : write unit tests for core functionality using `vitest`...
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T16:46:07.446Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js,jsx} : Write unit tests for core functionality using `vitest`

Applied to files:

  • packages/schema/src/types/schema.ts
📚 Learning: in `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distdir` are l...
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.

Applied to files:

  • packages/vite/src/vite-node.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: test-fixtures (ubuntu-latest, built, webpack, default, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-off, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, json, 20)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-off, json, 20)
  • GitHub Check: release-pkg-pr-new
  • GitHub Check: code

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 6, 2025

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@32874

nuxt

npm i https://pkg.pr.new/nuxt@32874

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@32874

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@32874

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@32874

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@32874

commit: df56143

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 6, 2025

CodSpeed Performance Report

Merging #32874 will not alter performance

Comparing fix/vite-node-options (df56143) with main (ecb4901)1

Summary

✅ 10 untouched benchmarks

Footnotes

  1. No successful run was found on main (eee55ea) during the generation of this report, so ecb4901 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@danielroe danielroe merged commit 5b11d48 into main Aug 11, 2025
76 of 84 checks passed
@danielroe danielroe deleted the fix/vite-node-options branch August 11, 2025 21:53
@github-actions github-actions bot mentioned this pull request Aug 11, 2025
@github-actions github-actions bot mentioned this pull request Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v4]: Request timeout while loading module

2 participants