Skip to content

feat(nuxt): expose getIslandHash + hashKey + improve hash for keys#35583

Merged
danielroe merged 9 commits into
mainfrom
feat/hash-function
Jul 15, 2026
Merged

feat(nuxt): expose getIslandHash + hashKey + improve hash for keys#35583
danielroe merged 9 commits into
mainfrom
feat/hash-function

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolves #34236 (comment)

📚 Description

two things:

  1. this exposes a hash function for libraries like nuxt-og-image to allow nuxt to tweak or change our algorithm for computing island hashes without inadvertently breaking everyone
  2. it also swaps out the implementation for computing keys for useFetch/useAsyncData with a smaller, faster one based on object-identity and fnv1a-64 (a tiny implementation of fnv-1a optimised for keys like this)

note that we don't see a bundle size improvement for (2) because we still use ohash for island keys, to avoid breaking anyone relying on the current implementation

@github-actions github-actions Bot added the 5.x label Jul 15, 2026
@danielroe danielroe changed the title feat(nuxt): expose getIslandHash + improve hash for keys feat(nuxt): expose getIslandHash + improve hash for keys Jul 15, 2026
@socket-security

socket-security Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedfnv1a-64@​0.1.1701009986100
Addedobject-identity@​0.2.3801009991100

View full report

@danielroe
danielroe force-pushed the feat/hash-function branch from 407e6e7 to a4fda97 Compare July 15, 2026 11:36
@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

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

@nuxt/nitro-server

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: 01ee2f6

@coderabbitai

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/nitro-server/src/runtime/handlers/island.ts`:
- Line 174: Remote island hash generation is inconsistent between server and
client. In packages/nitro-server/src/runtime/handlers/island.ts:174, update
expectedHash in the island handler to exclude source; in
packages/nuxt/src/app/components/nuxt-island.ts:108, remove source from the
client hashId inputs and incorporate it into the nuxtApp.payload.data cache key
instead, using a local fallback so identical islands from different sources do
not collide.

In `@packages/nuxt/src/app/composables/fetch.ts`:
- Around line 91-93: Update the plain-object branch in the fetch composable to
pass the already-unwrapped value directly to hashKey, removing the unnecessary
reactive wrapper while preserving the existing segment generation behavior.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 542ef458-16ca-4512-9025-b8da739e8025

📥 Commits

Reviewing files that changed from the base of the PR and between 58223f1 and e864260.

⛔ Files ignored due to path filters (2)
  • packages/nuxt/package.json is excluded by !**/package.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (12)
  • packages/nitro-server/src/runtime/handlers/island.ts
  • packages/nuxt/meta.js
  • packages/nuxt/src/app/components/nuxt-island.ts
  • packages/nuxt/src/app/composables/asyncData.ts
  • packages/nuxt/src/app/composables/component.ts
  • packages/nuxt/src/app/composables/fetch.ts
  • packages/nuxt/src/app/composables/hash.ts
  • packages/nuxt/src/app/index.ts
  • packages/nuxt/src/app/island-hash.ts
  • packages/nuxt/test/hash.test.ts
  • packages/nuxt/test/island-hash.test.ts
  • pnpm-workspace.yaml

Comment thread packages/nitro-server/src/runtime/handlers/island.ts
Comment thread packages/nuxt/src/app/composables/fetch.ts
@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 16.39%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 20 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
loadNuxt in the basic test fixture (dev) 374.5 ms 321.7 ms +16.39%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing feat/hash-function (01ee2f6) with main (a5c1086)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@danielroe danielroe changed the title feat(nuxt): expose getIslandHash + improve hash for keys feat(nuxt): expose getIslandHash + hashKey + improve hash for keys Jul 15, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/src/app/utils/hash.ts`:
- Around line 29-30: Update the native-function detection in the hash utility
around Function.prototype.toString.call(fn) to use a whitespace-tolerant regular
expression instead of the exact endsWith('[native code] }') check. Preserve the
existing native source formatting and fallback behavior while allowing
browser-specific newlines and spacing.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 04efe375-d3bd-4653-80f1-9e08737718e2

📥 Commits

Reviewing files that changed from the base of the PR and between a3d80c0 and ecbe529.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/nuxt/src/app/composables/asyncData.ts
  • packages/nuxt/src/app/composables/component.ts
  • packages/nuxt/src/app/composables/fetch.ts
  • packages/nuxt/src/app/index.ts
  • packages/nuxt/src/app/utils/hash.ts
  • packages/nuxt/test/hash.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/nuxt/test/hash.test.ts
  • packages/nuxt/src/app/composables/component.ts
  • packages/nuxt/src/app/composables/asyncData.ts
  • packages/nuxt/src/app/composables/fetch.ts
  • packages/nuxt/src/app/index.ts

Comment thread packages/nuxt/src/app/utils/hash.ts Outdated

@cernymatej cernymatej left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

❤️

Comment thread packages/nuxt/src/app/utils/hash.ts Outdated
Comment thread packages/nuxt/src/app/island-hash.ts Outdated
@danielroe
danielroe enabled auto-merge July 15, 2026 12:58
@danielroe
danielroe added this pull request to the merge queue Jul 15, 2026
@harlan-zw

Copy link
Copy Markdown
Contributor

Yess, thank you 🙏

Merged via the queue into main with commit cc313d1 Jul 15, 2026
31 checks passed
@danielroe
danielroe deleted the feat/hash-function branch July 15, 2026 13:56
This was referenced Jul 15, 2026
danielroe added a commit that referenced this pull request Jul 15, 2026
#35583)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
danielroe added a commit that referenced this pull request Jul 17, 2026
#35583)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request Jul 17, 2026
danielroe added a commit that referenced this pull request Jul 17, 2026
#35583)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
danielroe added a commit that referenced this pull request Jul 17, 2026
#35583)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
danielroe added a commit that referenced this pull request Jul 17, 2026
#35583)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
danielroe added a commit that referenced this pull request Jul 17, 2026
#35583)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useFetch key is not stable

3 participants