Skip to content

SSE client does not get notified of closed connection #84

@JoniLieh

Description

@JoniLieh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions