fix: replace bare except with except Exception in websocket_server.py - #218
Open
KeloYuan wants to merge 1 commit into
Open
fix: replace bare except with except Exception in websocket_server.py#218KeloYuan wants to merge 1 commit into
KeloYuan wants to merge 1 commit into
Conversation
The bare except: catches SystemExit and KeyboardInterrupt, which can mask critical signals during SSL handshake failures.
There was a problem hiding this comment.
Pull request overview
This PR improves exception handling in the WebSocket server’s TLS wrapping path by replacing a bare except: with except Exception: so that system-level exceptions (e.g., KeyboardInterrupt, SystemExit) are not swallowed during SSL socket setup.
Changes:
- Replaced a bare
except:withexcept Exception:aroundssl.wrap_socket(...)inWebSocketHandler.__init__.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+219
to
220
| except Exception: # Not sure which exception it throws if the key/cert isn't found | ||
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces bare
except:withexcept Exception:insrc/websocket_server.py(line 219).Context
The bare except wraps SSL socket creation. When key/cert files are not found, the bare except silently swallows all exceptions including
SystemExitandKeyboardInterrupt.Why
except Exception:preserves the same error handling behavior while respecting system-level exceptions likeKeyboardInterrupt(Ctrl+C) andSystemExit.