-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
[unhandledRejection] Cannot set headers after they are sent to the client #24
Comments
Same problem here. |
I'm gotting this error when use apollo subscription. Maybe h3 have problem with sockets? |
When i use my MacBook i got this error, but if i use ubuntu os it's work fine! |
This is not bug only in Nuxt 2 bridge, this hapnes in Nuxt 3 too, when you use Nuxt under reverse proxy (descripted by @Diizzayy here nuxt/nuxt#12003), Nitro, h3 or some base server logic in Nuxt part not process headers properly. @danielroe @pi0 |
I'm closing as there is no reproduction provided. If you can provide one, I'll happily reopen. |
@danielroe try run Nuxt3 Inside Docker with simple Nginx proxy_pass and you will get this error |
If you can provide me a reproduction, I'll do so 😊 |
I am getting this at times when I try to fetch a cookie with
server.mjs: router.beforeEach(async (to, from) => {
to.meta = __vite_ssr_import_0__.reactive(to.meta);
nuxtApp._processingMiddleware = true;
const middlewareEntries = new Set([...__vite_ssr_import_7__.globalMiddleware, ...nuxtApp._middleware.global]);
for (const component of to.matched) {
const componentMiddleware = component.meta.middleware;
if (!componentMiddleware) {
continue;
} line 2048 is the continue after |
What is the content of your middleware? |
import { useNuxtApp } from '#app'
export default defineNuxtRouteMiddleware(to => {
const { $api } = useNuxtApp()
if (to.path !== $api.config.redirect.logout && $api.loggedIn.value === false)
return navigateTo($api.config.redirect.logout)
}) I think I tracked it down to when I do this in my auth library: private getToken(): string {
if (this.config.req) return useCookie(this.config.req, 'token')
return this.cookies.get('token')
}
|
Same issue in Nuxt3 clean installation when I used public folder. Nuxt CLI v3.0.0-27449998.32cf973 ERROR [unhandledRejection] Cannot set headers after they are sent to the client at new NodeError (node:internal/errors:371:5) [Vue Router warn]: No match found for location with path "/__webpack_hmr/client" |
Could this be related to unjs/h3#21 & unjs/h3#35? |
Same issue while using Mac OS on Apple Silicon. I do not have the same issue on Ubuntu or Windows. |
I'm closing this as this should be resolved with #324. If you encounter this again, feel free to open a new issue with a reproduction. |
I encountered with this issue. Migrated existing Nuxt2 project with Nuxt Bridge ERROR [uncaughtException] Cannot set headers after they are sent to the client
at ClientRequest.setHeader (_http_outgoing.js:558:11)
at ProxyServer.<anonymous> (node_modules/nitropack/dist/chunks/prerender.mjs:2444:16)
at ProxyServer.emit (node_modules/eventemitter3/index.js:184:35)
at ClientRequest.<anonymous> (node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:133:16)
at ClientRequest.emit (events.js:327:22)
at ClientRequest.EventEmitter.emit (domain.js:467:12)
at tickOnSocket (_http_client.js:778:7)
at onSocketNT (_http_client.js:817:5)
at processTicksAndRejections (internal/process/task_queues.js:81:21) |
Environment
Describe the bug
Reproduction
Fresh install nuxt 2 and migrate to bridge following: https://v3.nuxtjs.org/getting-started/bridge
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: