Skip to content

Method stream closure can wait on paused input and stall shared socket traffic #5897

Done

Description

@marcelomendoncasoares

Closing a method stream can delay producer cancellation when its input subscription is paused. The individual output-close path invokes the controller cleanup before cancelling the output subscription, while that cleanup may be waiting for the producer to release the input. Cleanup can then wait for the six-second fallback.

There is a second part to the same lifecycle problem: the shared WebSocket dispatcher awaits an input-close command. An output-close command queued behind it cannot promptly release that paused producer, and other methods on the same socket also wait.

A regression scenario is two streaming method calls sharing one WebSocket, both with paused input subscriptions. Close the first method's input and then its output. The first producer and session should close promptly, while the second method still carries data and the socket still responds to ping. Reversing the close order and repeating a close command should also be safe. A producer that does not settle cancellation must retain bounded cleanup.

The proposed fix cancels the producer first and tracks asynchronous close operations without blocking the socket reader. Source inspection was performed against bfe8b78f3c9820f6319f9ef180a82c8f3e94d834; the accompanying PR includes real WebSocket regression cases. Their runtime validation is deferred to CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions