feat(nuxt): expose getIslandHash + hashKey + improve hash for keys#35583
Conversation
getIslandHash + improve hash for keysgetIslandHash + improve hash for keys
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
407e6e7 to
a4fda97
Compare
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (2)
packages/nuxt/package.jsonis excluded by!**/package.jsonpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (12)
packages/nitro-server/src/runtime/handlers/island.tspackages/nuxt/meta.jspackages/nuxt/src/app/components/nuxt-island.tspackages/nuxt/src/app/composables/asyncData.tspackages/nuxt/src/app/composables/component.tspackages/nuxt/src/app/composables/fetch.tspackages/nuxt/src/app/composables/hash.tspackages/nuxt/src/app/index.tspackages/nuxt/src/app/island-hash.tspackages/nuxt/test/hash.test.tspackages/nuxt/test/island-hash.test.tspnpm-workspace.yaml
Merging this PR will improve performance by 16.39%
|
| 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)
Footnotes
-
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. ↩
getIslandHash + improve hash for keysgetIslandHash + hashKey + improve hash for keys
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (6)
packages/nuxt/src/app/composables/asyncData.tspackages/nuxt/src/app/composables/component.tspackages/nuxt/src/app/composables/fetch.tspackages/nuxt/src/app/index.tspackages/nuxt/src/app/utils/hash.tspackages/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
|
Yess, thank you 🙏 |
#35583) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
#35583) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
#35583) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
#35583) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
#35583) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
#35583) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
🔗 Linked issue
resolves #34236 (comment)
📚 Description
two things:
nuxt-og-imageto allow nuxt to tweak or change our algorithm for computing island hashes without inadvertently breaking everyoneuseFetch/useAsyncDatawith 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