Skip to content

fix(dev): keep lazy handlers code-split in dev - #4459

Open
jibin7jose wants to merge 1 commit into
nitrojs:v2from
jibin7jose:fix-dev-lazy-handlers-v2
Open

fix(dev): keep lazy handlers code-split in dev#4459
jibin7jose wants to merge 1 commit into
nitrojs:v2from
jibin7jose:fix-dev-lazy-handlers-v2

Conversation

@jibin7jose

Copy link
Copy Markdown

Linked issue

Fixes #4435

Type of change

  • Documentation (updates to the documentation, readme, or JSdoc annotations)
  • Bug fix (a non-breaking change that fixes an issue)
  • Enhancement (improving an existing functionality like performance)
  • New feature (a non-breaking change that adds functionality)
  • Chore (updates to the build process or auxiliary tools and libraries)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This fixes a bug in the nitro-dev preset where an import-time error in a single lazy route handler takes down the entire dev server and breaks unrelated routes with a misleading Cannot access '<x>' before initialization error.

Cause:
The nitro-dev preset was setting inlineDynamicImports: true. This caused Rollup to inline all lazy handler bodies into the single index.mjs startup bundle. An error evaluating one route would abort the execution of the bundle, leaving subsequent routes permanently in the Temporal Dead Zone (TDZ).

Fix:
Set inlineDynamicImports: false in the nitro-dev preset. This ensures lazy handlers remain code-split during local development, so an import-time failure in one module will not disrupt the evaluation of the rest of the server or other routes. When a broken route is accessed, the dev server will now accurately report the original initialization error.

(Note: This PR is functionally equivalent to #4436 and #4458, but properly targets the v2 branch where this issue actually affects users.)

@jibin7jose
jibin7jose requested a review from pi0 as a code owner July 22, 2026 06:08
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

@jibin7jose is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a6ef6dc5-1f21-41c2-8482-28b63b67950b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant