spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

Connection leak - CircuitBreak Filter + Chunked 500 Response

Open tiliveanic opened this issue 1 month ago • 0 comments

Describe the bug When combining the Circuit Break Filter configured with a 500 status code & a fallback - when the SCG receives a 'slow' chunked 500 response from the upstream, it fallbacks and, as a side-effect, it will leak a connection towards the first upstream, eventually leading to connection pool exhaustion & essentially block of the routes.

Sample Here is the routes config :

       - id: cbroute
          predicates:
            - 'Path=/chunked/delayed'
          uri: 'https://first.com'
          filters:
            - name: CircuitBreaker
              args:
                name: lfs-cb
                fallbackUri: 'forward:/fallback'
                statusCodes: '500'
        - id: cbfallback
          predicates:
            - 'Path=/fallback'
          uri: 'https://second.com'
          filters:
            - 'SetPath=/one'

When the chunked response comes fast enough the issue does not reproduce.

Here is a repo with the reproduction scenario using WireMock https://github.com/tiliveanic/scg-cb-chunked-bug

tiliveanic avatar Nov 14 '25 15:11 tiliveanic