httpxy icon indicating copy to clipboard operation
httpxy copied to clipboard

SSE client does not get notified of closed connection

Open JoniLieh opened this issue 4 months ago • 0 comments

Environment

"nuxt": "^4.0.3" -> "nitropack": "2.12.4" -> "httpxy": "^0.1.7" node v20.18.3 npm 11.2.0

Reproduction

...
nitro: {
    // routeRules: {
    //   '/api/**': {
    //     proxy: "http://localhost:33001/api"+ '/**', // https://nitro.build/guide/routing#route-rules
    //   }
    // },
    devProxy: {
      '/api': {
        target: "http://localhost:33001/api",
        changeOrigin: true,
        secure: false,
        timeout: 0,
        proxyTimeout: 0,
      }
    }
}

Describe the bug

Hello there, Im trying to use a SSE connection with the nitro proxy:

...
nitro: {
    // routeRules: {
    //   '/api/**': {
    //     proxy: "http://localhost:33001/api"+ '/**', // https://nitro.build/guide/routing#route-rules
    //   }
    // },
    devProxy: {
      '/api': {
        target: "http://localhost:33001/api",
        changeOrigin: true,
        secure: false,
        timeout: 0,
        proxyTimeout: 0,
      }
    }
}

The proxy works fine for normal HTTP requests and even for SSE. BUT when the server (my custom backend) which provides the SSE endpoint turns down the stream / I turn off the server, the client doesn't get the notification of the closed stream and still thinks the stream is good. I tested without the proxy, and it worked fine, both routeRules and devProxy doesn't work. In nitroApp.hooks.hook('error'...) I only get a 500 terminated when cutting off the backend.

Additional context

No response

Logs


JoniLieh avatar Aug 27 '25 23:08 JoniLieh