nuxt: request error Context conflict
Environment
- Operating System:
Linux - Node Version:
v16.17.1 - Nuxt Version:
3.3.3 - Nitro Version:
2.3.2 - Package Manager:
pnpm@7.28.0 - Builder:
vite - User Config:
srcDir,debug,typescript,app,experimental,vite,modules,i18n,tailwindcss,vueuse,routeRules,imports,components,runtimeConfig - Runtime Modules:
@nuxt/devtools@0.1.6,@nuxtjs/i18n@8.0.0-beta.9,@nuxtjs/tailwindcss@6.6.5,@vueuse/nuxt@9.13.0,@nuxt/image-edge@1.0.0-27919678.2f5b64b,@pinia/nuxt@0.4.7 - Build Modules:
-
Reproduction
Has not
Describe the bug
[nuxt] [request error] [unhandled] [500] Context conflict at checkConflict (./server/node_modules/unctx/dist/index.mjs:6:13) at Object.call (./server/node_modules/unctx/dist/index.mjs:31:7) at contextCaller (./server/chunks/app/_nuxt/entry-a7e1e255.mjs:333:26) at Hookable.callHookWith (./server/node_modules/hookable/dist/index.mjs:198:20) at Hookable.nuxtApp.hooks.callHook (./server/chunks/app/_nuxt/entry-a7e1e255.mjs:336:63) at ./server/chunks/handlers/renderer.mjs:372:32 at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ./server/chunks/handlers/renderer.mjs:16:22 at async Object.handler (./server/node_modules/h3/dist/index.mjs:1247:19) at async Server.toNodeHandle (./server/node_modules/h3/dist/index.mjs:1322:7)
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 21 (5 by maintainers)
SUMMARY: Same problem since Nuxt 3.3.2 for us too.
Downgrading to 3.3.1 solved this issue for us at the moment.
We’ve also tried https://github.com/nuxt/nuxt/pull/19753#issuecomment-1490508304 to resolve this without success.
We’re on Node 18.16.0 if that’s of any relevance.
EDIT: No wonder that this was confusing - I think there is a bug with the i18n-module, that somehow messes up the router/ssrcontext, and we didn’t really notice this up until now. We found out about this when looking into the context-conflict and at first they seemed related, but they are not related at all. Sorry for the confusion here.
Also the original post mixes up two different issues, so feel free to ignore the rest of it. 😃
FYI: We already had those in 3.3.1. We didn’t notice them for quite some time sadly. EDIT: Seems like i was wrong about this, and 3.3.2 broke it
I’m not super sure if this is related to this problem specifically, since we have another construction site with Nuxt Instance Unavailable. So take this with a grain of “this might be a different problem with similar symptoms”. What happens with our App is quite…odd:
So imagine you open the website and just take 5 links and open them in a new Tab at the same time.
What happens so far was, that in our App.vue everything seems fine and all URLs/Paths look right.
But down the road in an (async) composable it’s suddenly all the same URL/Path.
It’ll look something like this:
This results either complete Errors with the Context-Issue OR you get a fully rendered page but with the content of
/aeven though you’re clearly on/b(in your browser-url).Now reproducing this…well. I’m still looking into where things actually go south and what’s related to what, but maybe this helps you guys a little?
So after further debugging: The wrong paths only happen with useRouter, while useRoute returns the right path
— Merged other reply into this — So, for us it seem’s our own Plugin that does some stuff with the router due to our site being used on multiple domains + languages, but our url structure won’t indicate that.
And then since we use i18n but we DONT want prefixed URLs, we remove the prefixes from the routes in our Plugin.
Basically we’re getting our routes, remove a lot of them, and only give back the right ones for the domain/language combination, that’s the gist of it.
What’s funny is, that useRoute().path will provide the right path, while useRouter().router.currentRoute.value.path will have a wrong path from a previous request.
Sorry for the bad explanation, we’re in the middle of troubleshooting this.
EDIT: So we were missing one await - so far so good, doesn’t really seem to change anything. 😦
Open issue in i18n package: https://github.com/nuxt-modules/i18n/issues/1984
We are in version 3.3.1 waiting for a fix.
any update? 😃
thanks guys
Indeed, I think this might be an issue we need to investigate.
cc: @pi0
@danielroe https://stackblitz.com/edit/nuxt-issue-20070
It is also related to the package “@nuxtjs/i18n” and “useCookie”.
1. On a clean nuxt 3 project, install: “@nuxtjs/i18n”: “^8.0.0-beta.10”
2. Create global middleware like this:
3. Use siege and gtimeout to send multiple concurrent requests: brew install siege
brew install coreutils gtimeout 30 siege -c 5 http://localhost:3000
then sometimes I will get the error: [nuxt] [request error] [unhandled] [500] Context conflict
@EduardoMateos As you said, the problem was solved after we changed the nuxt version to 3.3.0. Hope the Nuxt team can solve this problem soon
@danielroe its strange because it happened randomly (multiple concurrent requests) 3/10 throws an context error, the normal error “Nuxt instance is unavailable” it not thrown.
I’m seeing this error in production (PM2) and I don’t know what causes it. If I find the reason I will create a reproduction.