Skip to content

Conversation

@lazercaveman
Copy link
Contributor

🔗 Linked issue

Resolves #33579

📚 Description

This PR adds error handling for the missing client.precomputed.mjs file in the renderer utility to prevent build crashes when the file is not generated.

Problem:
The getPrecomputedDependencies() function currently imports client.precomputed.mjs without a .catch() handler. When this file doesn't exist (for reasons still being investigated), the import fails and causes the entire build to crash in production environments. Development builds work fine because precomputed is set to undefined when import.meta.dev is true.

Solution:
Added a .catch() handler to getPrecomputedDependencies() that:

  • Returns an empty object {} as a fallback when the file is missing
  • Logs a warning in development mode to alert developers about the missing file
  • Prevents the application from crashing while maintaining the old lazy-loading behavior

This graceful degradation approach ensures builds don't fail while we investigate the root cause of why client.precomputed.mjs isn't being generated in certain scenarios.

Testing:

  • Tested in production build with manually deleted client.precomputed.mjs
  • Verified fallback behavior matches the empty object workaround
  • Confirmed warning appears in development console when file is missing

@bolt-new-by-stackblitz
Copy link

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 27, 2025

Open in StackBlitz

@nuxt/kit

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: ea35776

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Walkthrough

A .catch fallback is added to the import chain for getPrecomputedDependencies in the build-files utility. If the client.precomputed.mjs file is unavailable, the fallback logs a warning during development and resolves to an empty object whilst maintaining the PrecomputedData structure. The control flow shifts from a direct import to a guarded resolution with runtime error handling. Public function signatures remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file modification with focused error handling logic
  • Straightforward .catch pattern addition to an existing import chain
  • No public API changes or structural reorganisation
  • Consider verifying the warning message clarity and that the empty object fallback adequately satisfies downstream consumers

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "fix: handle missing client.precomputed.mjs" is concise, clear, and directly summarises the main change in the changeset. It specifically identifies what is being fixed—the missing file handling—and relates to the core modification in the renderer utility. The title is not vague or generic, and a developer scanning the repository history would immediately understand that this PR addresses error handling for a missing file.
Linked Issues Check ✅ Passed The PR addresses the primary objectives from linked issue #33579. The change adds error handling to prevent build crashes when client.precomputed.mjs is missing, which directly resolves the reported issue where running yarn dev fails with an ENOENT error. The implementation provides a fallback mechanism (empty object), prevents application crashes, and includes a warning in development mode, meeting the core requirements for graceful degradation whilst the root cause is investigated. The PR does not attempt to fix why the file is missing, but this is acknowledged as "reasons still being investigated" and is outside the scope of this mitigation.
Out of Scope Changes Check ✅ Passed The PR contains no out-of-scope changes. The modification is confined to packages/nitro-server/src/runtime/utils/renderer/build-files.ts and involves only the addition of a .catch() handler to the getPrecomputedDependencies import chain. This change is directly scoped to addressing the missing file handling issue identified in #33579. No unrelated modifications or refactoring are present, and the PR maintains backwards compatibility by preserving the existing function signature and lazy-loading behaviour.
Description Check ✅ Passed The PR description is clearly related to the changeset and provides meaningful context about the changes. It explains the problem (missing file causes import failures), the solution (adding a .catch() handler with fallback logic), and testing performed. The description includes details about expected behaviour and confirms the change addresses the linked issue. This level of detail exceeds the minimum requirement for the description check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 72a1cc6 and 55fffef.

📒 Files selected for processing (1)
  • packages/nitro-server/src/runtime/utils/renderer/build-files.ts (1 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/nitro-server/src/runtime/utils/renderer/build-files.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). (2)
  • GitHub Check: build
  • GitHub Check: code

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 and usage tips.

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f54e16 and 4b8d8f9.

📒 Files selected for processing (1)
  • packages/nitro-server/src/runtime/utils/renderer/build-files.ts (1 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/nitro-server/src/runtime/utils/renderer/build-files.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). (2)
  • GitHub Check: build
  • GitHub Check: code
🔇 Additional comments (1)
packages/nitro-server/src/runtime/utils/renderer/build-files.ts (1)

33-33: No issues found; type contract appears satisfied.

The code at line 33 returns an empty object {} as a fallback when the precomputed dependencies file fails to import. However, examination of the codebase reveals this is intentional and correct:

  1. The function is explicitly type-cast as Promise<PrecomputedData>, indicating the developer has considered the type contract.

  2. In development mode, precomputed is set to undefined rather than relying on the fallback, meaning the empty object return is only used in production when the file import actually fails—a rare edge case.

  3. The vite-node plugin explicitly exports undefined for precomputed data in development, confirming that PrecomputedData can accept empty or undefined values.

  4. Build-time generation of precomputed data occurs in webpack and Vite manifests via precomputeDependencies(manifest), suggesting PrecomputedData is a map/object structure where an empty object represents "no precomputed dependencies."

  5. Error handling includes a dev warning message, showing deliberate fallback design.

The pattern is sound: the empty object fallback satisfies the type contract as a valid representation of absent precomputed dependencies.

@lazercaveman lazercaveman changed the title fix issue fix: handle missing client.precomputed.mjs gracefully Oct 27, 2025
@lazercaveman lazercaveman changed the title fix: handle missing client.precomputed.mjs gracefully fix: handle missing client.precomputed.mjs Oct 27, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 27, 2025

CodSpeed Performance Report

Merging #33585 will not alter performance

Comparing lazercaveman:fix/could-not-load-client-precomputed-mjs (ea35776) with main (b688187)

Summary

✅ 10 untouched

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.

Error: Could not load client.precomputed.mjs

1 participant