Skip to content

When request is aborted, cancel event is not propagated to downstream services. #1751

Open
@joaobologna

Description

@joaobologna

When a request is aborted by the client, spring-cloud-gateway is aware of it by Subscription.cancel(). Adding a filter can easily comprove this behavior, where

override fun apply(config: Config?): GatewayFilter {
    return GatewayFilter { exchange, chain ->
        chain.filter(exchange)
                .log()
                .doOnCancel { log.info { "ABORTED" } }
    }
}

when a request is canceled, generates

2020-06-01 11:20:03.824 INFO t=boundedElastic-7 reactor.Mono.LiftFuseable.1 - | onSubscribe([Fuseable] ScopePassingSpanSubscriber)
2020-06-01 11:20:03.824 INFO t=boundedElastic-7 reactor.Mono.LiftFuseable.1 - | request(unbounded)
2020-06-01 11:20:04.639 INFO t=reactor-http-epoll-2 p.s.g.s.filter.GatewayLogFilter - ABORTED
2020-06-01 11:20:04.640 INFO t=reactor-http-epoll-2 reactor.Mono.LiftFuseable.1 - | cancel()

But if it was routed to a downstream service, SCG does not notifies the service. I don't know if this should be default but, at least, should be configurable.

Looking at NettyRoutingFilter, only when a response is recieved, CLIENT_RESPONSE_CONN_ATTR is set as an exchange attribute, later used in NettyWriteResponseFilter#(cleanup) to dispose the call using doOnCancel event.

Version:

  • spring-cloud-gatway: 2.2.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions