-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(nuxt): do not include components of key in useFetch
watch sources
#31903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/vite-builder
@nuxt/webpack-builder
@nuxt/schema
commit: |
WalkthroughThe changes in this update focus on the internal implementation of the 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Nitpick comments (2)
packages/nuxt/src/app/composables/fetch.ts (1)
96-103
: Third-argument “autoKey” is now ignored – remove or deprecate explicitly
useFetch()
still accepts a third positional argument (passed byuseLazyFetch
) but it is silently discarded after the refactor.
Leaving a seemingly-supported parameter that has no effect can confuse end-users or internal contributors.Consider either:
- Removing the
arg2
parameter entirely (and adjustinguseLazyFetch
), or- Emitting a deprecation warning when a truthy
arg2
is supplied, explaining that custom keys should now be provided viaopts.key
.This keeps the public surface predictable and avoids future maintenance surprises.
test/nuxt/composables.test.ts (1)
637-654
: Clean up test-specific endpoints to avoid cross-test bleed-through
registerEndpoint
adds global handlers that persist for the whole Vitest run.
If another suite registers the same path (/api/initial
or/api/updated
) with different behaviour, tests may interfere with one another.Add a teardown to remove or overwrite these endpoints after the case finishes:
const unregisterInitial = registerEndpoint('/api/initial', defineEventHandler(() => ({ url: '/api/initial' }))) const unregisterUpdated = registerEndpoint('/api/updated', defineEventHandler(() => ({ url: '/api/updated' }))) try { // ...test logic... } finally { unregisterInitial?.() unregisterUpdated?.() }(or push the registrations into
beforeEach
/afterEach
).This keeps the test suite hermetic and prevents flaky failures when tests run in parallel.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/nuxt/src/app/composables/fetch.ts
(3 hunks)packages/nuxt/src/core/plugins/composable-keys.ts
(0 hunks)packages/schema/src/config/build.ts
(0 hunks)test/nuxt/composables.test.ts
(1 hunks)
💤 Files with no reviewable changes (2)
- packages/schema/src/config/build.ts
- packages/nuxt/src/core/plugins/composable-keys.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build
- GitHub Check: code
CodSpeed Performance ReportMerging #31903 will not alter performanceComparing Summary
|
if (!_key.value || typeof _key.value !== 'string') { | ||
throw new TypeError('[nuxt] [useFetch] key must be a string: ' + _key.value) | ||
const key = computed(() => toValue(opts.key) || ('$f' + hash([typeof _request.value === 'string' ? _request.value : '', ...generateOptionSegments(opts)]))) | ||
if (!key.value || typeof key.value !== 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still needed ? key should be always Ref<string>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not!
🔗 Linked issue
resolves #31896
📚 Description
For some fetch options, they both affect the generation of the hashed key and are manually added via
fetchOptions
.This PR:
removes auto-generating keys fromuseFetch
(as this was never being used)key