Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(p2p-listener): ensure safe type assertion in stream handling #10690

Closed

Conversation

gitsrc
Copy link

@gitsrc gitsrc commented Feb 3, 2025

  • Replace direct type assertion with a safe type check and nil check
  • Prevent potential runtime panics by ensuring remoteListener is valid

[skip changelog]

@gitsrc gitsrc requested a review from a team as a code owner February 3, 2025 13:45
@gitsrc gitsrc changed the title refactor(p2p-listener): ensure safe type assertion in stream handling improve(p2p-listener): ensure safe type assertion in stream handling Feb 3, 2025
Comment on lines -55 to -56
if l != nil {
go l.(*remoteListener).handleStream(stream)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

triage notes: @gitsrc when was this causing panic? fixing the underlying issue sounds like the right way, we dont want to silence the error

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the note! To clarify, no panic has actually occurred. While reading and learning this part of the code, I felt it could use some additional robustness to prevent potential issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. for sure we don't want to hide the problem if it ever occurs, as that will be painful to debug.

I'm leaning towards closing this PR unless convinced there is net value add in doing this (panic repro or description of why its ok to ignore panic).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it.

@lidel lidel added the need/author-input Needs input from the original author label Feb 4, 2025
@gitsrc gitsrc closed this Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/author-input Needs input from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants