Skip to content

[BUG] — WebClientMessageWriter: no doOnError/doOnCancel on chain.execute → upstream response body Flux never drained on mid-chain error/cancel → connection pool leak #6793

Description

@Aias00
  • severity: Medium-High
  • files: shenyu-plugin/shenyu-plugin-response/src/main/java/org/apache/shenyu/plugin/response/strategy/WebClientMessageWriter.java:70
  • description: The ResponseEntity<Flux<DataBuffer>> set into CLIENT_RESPONSE_ATTR by WebClientPlugin holds a lazy body Flux; the reactor-netty connection is not returned to the pool until that Flux is subscribed and drained/cancelled. onErrorResume/doOnCancel here only cover errors during exchange.getResponse().writeWith(body) (inside the defer); there is no guard on chain.execute(exchange) itself. If any plugin running after the WebClient call throws or the chain is cancelled, the defer is never reached, the body Flux is never subscribed, and the connection is held until the client idle/recv timeout. Sibling NettyClientMessageWriter.java:59,82 correctly guards the same path with doOnError/doOnCancelcleanup(exchange).
  • impact: Leaked upstream connections (not returned to the WebClient/reactor-netty pool) on any mid-chain failure; pool starvation under sustained mid-chain failures.
  • suggested_fix: Add .doOnError(e -> clean(exchange)).doOnCancel(() -> clean(exchange)) to chain.execute(exchange) at line 70, mirroring NettyClientMessageWriter (clean already drains/releases the body at line 128).
  • confidence: Medium-High

Identified during the 2026-08-02 deep re-scan; full list in docs/scan2-2026-08-02/06-medium-tiers.md.

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