Skip to content

Fix WebBrokerApi closed-channel panics#1982

Draft
leno23 wants to merge 1 commit into
wso2:mainfrom
leno23:fix/webbrokerapi-closed-channel
Draft

Fix WebBrokerApi closed-channel panics#1982
leno23 wants to merge 1 commit into
wso2:mainfrom
leno23:fix/webbrokerapi-closed-channel

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Purpose

Resolves #1959.

The WebBrokerApi inbound and outbound loops read from per-connection channels without checking whether the channels were closed. A closed channel receive returns a nil *connectors.Message, and the loops then dereference msg.Value, which can panic during connection teardown.

Goals

  • Make WebBrokerApi teardown safe when inbound or outbound channels are closed.
  • Add regression coverage for closed-channel loop exits.

Approach

  • Use the Go comma-ok channel receive pattern in both inboundLoop and outboundLoop.
  • Return immediately when the channel is closed or a nil message is received.
  • Add unit tests that close each channel and assert the loop returns without panicking.

User stories

N/A — bug fix for connection teardown robustness.

Documentation

N/A — internal panic guard only; no user-facing API or configuration change.

Automation tests

  • Unit tests
    • go test ./internal/connectors/receiver/websocket
  • Integration tests
    • go test ./internal/connectors/receiver/...
    • go test ./... from event-gateway/gateway-runtime

Security checks

Samples

N/A.

Related PRs

N/A.

Test environment

macOS Darwin 24.5.0 arm64; Go 1.26.2.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05a57057-5a87-48bc-80f1-2170c10d7143

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebBrokerAPI: Guard channel reads with comma-ok pattern in WebBrokerApi receiver to prevent nil-message panics

2 participants