Skip to content

Conversation

@huang-julien
Copy link
Member

🔗 Linked issue

fix #33844

📚 Description

This PR fixes a bug where multiple head inputs will result in only having the last input being set in the islandHead Object due to a missing else statement.

@bolt-new-by-stackblitz
Copy link

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

@huang-julien huang-julien marked this pull request as ready for review December 10, 2025 18:15
@huang-julien huang-julien changed the title fix(nuxt): avoid overwriting multiple styles fix(nuxt): avoid overwriting multiple head input Dec 10, 2025
@huang-julien huang-julien changed the title fix(nuxt): avoid overwriting multiple head input fix(nuxt): avoid overwriting multiple head input in island handler Dec 10, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Walkthrough

The change modifies the head entry merging logic for islands in the runtime handler. The update refines how values are processed during iteration over head entries. When encountering a new value for an existing key containing an array, the new value is now pushed into that array. For non-array values, direct assignment occurs as before. Previously, the code performed direct assignment regardless of the existing value type, which could overwrite array contents.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description is directly related to the changeset, explaining the bug fix for multiple head inputs being overwritten due to a missing else statement.
Linked Issues check ✅ Passed The code changes address the root cause identified in issue #33844 by preserving multiple head inputs instead of overwriting them, which should resolve the lost styles in nested NuxtIsland components.
Out of Scope Changes check ✅ Passed The changes are scoped to the island head merging logic in the island handler, directly addressing the bug described in the linked issue without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title directly addresses the main fix: preventing overwriting of multiple styles in nested island head merging logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/nested_island

Tip

✨ Issue Enrichment is now available for GitHub issues!

CodeRabbit can now help you manage issues more effectively:

  • Duplicate Detection — Identify similar or duplicate issues
  • Related Issues & PRs — Find relevant issues and PR's from your repository
  • Suggested Assignees — Find the best person to work on the issue
  • Implementation Planning — Generate detailed coding plans for engineers and agents
Disable automatic issue enrichment

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

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

🧹 Nitpick comments (1)
packages/nitro-server/src/runtime/handlers/island.ts (1)

86-90: Fix correctly addresses the overwriting issue.

The addition of the else clause properly solves the bug where multiple head inputs were being overwritten. Previously, the assignment on line 89 would execute unconditionally after the if block, negating the array push operation. Now, array values are correctly preserved and extended whilst non-array values are assigned only when appropriate.

Optional: Consider defensive type checking.

Whilst the current logic should work correctly with proper Unhead usage, consider adding a type check for robustness:

 if (Array.isArray(currentValue)) {
-  currentValue.push(...value)
+  if (Array.isArray(value)) {
+    currentValue.push(...value)
+  } else {
+    currentValue.push(value)
+  }
 } else {
   islandHead[key as keyof SerializableHead] = value
 }

This guards against edge cases where value might not be an array even when currentValue is, preventing potential runtime errors.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86d67b2 and ccd4360.

📒 Files selected for processing (1)
  • packages/nitro-server/src/runtime/handlers/island.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • packages/nitro-server/src/runtime/handlers/island.ts
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx,js,jsx,vue}: Use clear, descriptive variable and function names
Add comments only to explain complex logic or non-obvious implementations
Keep functions focused and manageable (generally under 50 lines), and extract complex logic into separate domain-specific files
Remove code that is not used or needed
Use error handling patterns consistently

Files:

  • packages/nitro-server/src/runtime/handlers/island.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). (19)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, webpack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite-env-api, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite-env-api, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, rspack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, rspack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite-env-api, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite-env-api, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite-env-api, default, manifest-on, json, lts/-1)
  • GitHub Check: release-pkg-pr-new
  • GitHub Check: test-size
  • GitHub Check: typecheck (ubuntu-latest, bundler)
  • GitHub Check: typecheck (windows-latest, bundler)
  • GitHub Check: test-benchmark
  • GitHub Check: code

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 10, 2025

Open in StackBlitz

@nuxt/kit

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

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@33849

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: ccd4360

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 10, 2025

CodSpeed Performance Report

Merging #33849 will not alter performance

Comparing fix/nested_island (ccd4360) with main (ac906ce)1

Summary

✅ 10 untouched

Footnotes

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

@danielroe danielroe merged commit 7fd6b72 into main Dec 12, 2025
58 checks passed
@danielroe danielroe deleted the fix/nested_island branch December 12, 2025 12:55
@github-actions github-actions bot mentioned this pull request Dec 12, 2025
This was referenced Dec 15, 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.

Nesting the use of NuxtIsland seems to cause the loss of styles in the inner components.

3 participants