Skip to content

fix: prevent panic on closed channel onPing#410

Open
avonbirgelen wants to merge 2 commits intolorenzodonini:masterfrom
pxc-smart-business:master-lornzodonini
Open

fix: prevent panic on closed channel onPing#410
avonbirgelen wants to merge 2 commits intolorenzodonini:masterfrom
pxc-smart-business:master-lornzodonini

Conversation

@avonbirgelen
Copy link
Copy Markdown

@avonbirgelen avonbirgelen commented Mar 16, 2026

Proposed changes

I am experiencing a panic in some situations related to the Websocket Ping/Pong.
It seems that in some cases (i assume unstable connections but I have been unable to reproduce this in my tests), the connection is being cleaned up and the OnPing still tries to write to the pingC channel, resulting in "panic: send on closed channel".

This should fix that issue.

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of
them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before
merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

@avonbirgelen avonbirgelen changed the title Prevent panic on closed channel Prevent panic on closed channel onPing Mar 16, 2026
@avonbirgelen
Copy link
Copy Markdown
Author

On Second thought. Not sure if this is enough. I have not been able to reliably reproduce the error. So I am unsure if this catches the panic, or just reacts when the channel is full.
Will do some more testing on my end and update this PR. Or feel free to close it.

@avonbirgelen avonbirgelen marked this pull request as draft March 16, 2026 07:30
@avonbirgelen avonbirgelen marked this pull request as ready for review March 20, 2026 11:43
@avonbirgelen avonbirgelen changed the title Prevent panic on closed channel onPing fix: prevent panic on closed channel onPing Mar 20, 2026
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.

1 participant