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
cross-request state pollution when useAsyncData
is used in a plugin
#19623
Comments
confirming this also happens with |
@danielroe @pi0 found the culprit within the fixtures... Looks like
|
We perform an |
adding |
Aha. That's very helpful. It may be a bug in |
useFetch
is used in a plugin
also with export default defineNuxtPlugin(async ( nuxtApp ) => {
const config1 = useRuntimeConfig()
await new Promise(resolve => setTimeout(resolve, 100))
const { data } = useAsyncData('hey', () => {
return $fetch('/api/hey')
})
const config2 = useRuntimeConfig()
return {
provide: {
asyncPlugin: () => config1 && config1 === config2
? 'Async plugin works! ' + config1.testConfig + (data.value?.baz ? 'useFetch works!' : 'useFetch does not work')
: 'Async plugin failed!'
}
}
}) |
useFetch
is used in a pluginuseAsyncData
is used in a plugin
Environment
Windows_NT
v18.15.0
3.2.3
2.2.3
pnpm@7.29.1
vite
-
-
-
Reproduction
https://github.com/huang-julien/nuxt/tree/test/xrps-server-component
This repo contains the content of #19605
Run the fixtures in dev and go to
/islands
Refresh 5-6 time, you should see that
PureComponent
get replaced by the result ofAsyncServerComponent
You can also do it at
/
but you'd need to leave your finger on F5 for 2-3sec.Check the console. There's 2 value, they should always be the same. The first one is an array length, the second one a Set size.
Describe the bug
When there's a very high rate of request with sync component server side (just leave you're finger on F5), sometimes the app instance retrieved from unctx with
useNuxtApp
does not belong to the current instance of vue App.It seems that this does not apply to pages rendering but only when requesting for server components.
Additional context
Found when working on #19605. It is way easier to reproduce it with async components
discussed with @danielroe
Logs
No response
The text was updated successfully, but these errors were encountered: