Under the SEP-2575 path, ClientSession.Subscribe starts a subscriptions/listen request without awaiting the stream response. If the session has already started closing, or if Close races with Subscribe startup, Subscribe can return nil even though the listen stream was cancelled or rejected. In that case the local resourceSubs map can also keep an entry for a subscription that was never successfully started.
Reproduction:
- Connect a ClientSession with protocolVersion20260728.
- Close the session, or have Close start while Subscribe is entering the subscriptions/listen send path.
- Call Subscribe for a resource URI.
Expected:
Subscribe reports ErrConnectionClosed and does not leave a local resource subscription registered.
Actual:
Subscribe can report success or context cancellation without consistently rolling back the resource subscription entry.
Environment:
go version go1.26.5 darwin/arm64
Under the SEP-2575 path, ClientSession.Subscribe starts a subscriptions/listen request without awaiting the stream response. If the session has already started closing, or if Close races with Subscribe startup, Subscribe can return nil even though the listen stream was cancelled or rejected. In that case the local resourceSubs map can also keep an entry for a subscription that was never successfully started.
Reproduction:
Expected:
Subscribe reports ErrConnectionClosed and does not leave a local resource subscription registered.
Actual:
Subscribe can report success or context cancellation without consistently rolling back the resource subscription entry.
Environment:
go version go1.26.5 darwin/arm64