Description
Affects: Spring: 6.0.2 spring-boot: 3.0.0
I have noticed that spring-webflux
application with endpoint that returns Mono<T>
on WebFilter
invocation sometimes receives already canceled Mono
. I was able to notice this behaviour only when controller performs some async operation like IO
or delayElement
. Also I was able to reproduce only when controller returns Mono<T>
but not Flux<T>
.
I have found issue that express similar problem though it is marked as fixed :
#22952
I have created demo app that help to detect this behaviour:
https://github.com/zygisx/webflux-canceled-mono
Simple WebFilter logs whenever it gets already canceled Mono
Test that performs many requests to running server (have to start up Demo application before running test). Test shows that all requests from client perspective completed successfully and was not canceled prior.
In production we are using WebFiler to record request metrics, and ±10% of our request falls into this trap, where mono is canceled. This makes us blind whether request was actually canceled by client or its caused by underlying issue in spring-framework ?