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

Fix: Add WebSocket existence check before checking readyState #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WlanKabL
Copy link

This PR adds a check to ensure that the this.websocket object exists before attempting to access its readyState. This prevents runtime errors when trying to disconnect or interact with an undefined or null WebSocket instance.

Why this change?
Without this change, attempting to access this.websocket.readyState when this.websocket is null or undefined will cause a runtime error. This update ensures a safer check for the WebSocket state, preventing potential crashes.

Testing:
Tested by simulating cases where this.websocket might not be defined. Verified that the program no longer crashes and behaves correctly when trying to disconnect or check WebSocket status.

@WlanKabL WlanKabL changed the title Bugfix isConnected crash Fix: Add WebSocket existence check before checking readyState Sep 27, 2024
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