WebBrokerAPI: Fix: Avoid closing shared channels in WebBrokerApi closeConnection to prevent panics
@senthuran16 is already working on this.
Since May 14, 2026.
- Dominant language
- Go
- Stars
- 71
- Forks
- 111
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 110
Description
Summary
In event-gateway/gateway-runtime/internal/connectors/receiver/websocket/broker_api_connector.go, the closeConnection method currently closes the conn.inbound and conn.outbound channels directly during teardown. This can cause panics when other goroutines (e.g., the broker consumer callback) are still attempting to send to these channels concurrently.
Problem
close(conn.inbound)
close(conn.outbound)
Since the broker callback goroutine may still be writing to conn.outbound after closeConnection is called, closing the channel here can result in a "send on closed channel" panic.
Proposed Fix
- Remove the
close(conn.inbound)andclose(conn.outbound)calls fromcloseConnection. - Rely on context cancellation (already present via
conn.cancel()) and consumer stop as the shutdown signal. - Ensure goroutines that own/read these channels are responsible for closing them when appropriate, after observing context cancellation.
- Document that
conn.outboundis not closed by teardown to avoid races with broker callback sends.
References
- PR: https://github.com/wso2/api-platform/pull/1954#discussion_r3239562637
- Related: https://github.com/wso2/api-platform/pull/1944
Requested by @senthuran16
Contributor guide
No contributing guide indexed for this repository
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.
Assessment
This issue has not been assessed yet.