spring-cloud / spring-cloud/spring-cloud-gateway
When request is aborted, cancel event is not propagated to downstream services.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with NettyRoutingFilter and NettyWriteResponseFilter#(cleanup), focusing on CLIENT_RESPONSE_CONN_ATTR and the existing doOnCancel handling. Reproduce a client-aborted request routed to a downstream service, then determine whether cancellation reaches that service and how configurable propagation should be verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100