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

ResetWithoutClosingHandshake #6

Closed
wd7bxscience opened this issue May 16, 2024 · 1 comment
Closed

ResetWithoutClosingHandshake #6

wd7bxscience opened this issue May 16, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@wd7bxscience
Copy link
Collaborator

When the frontend attempts to start the websocket, it is met with error code 1006. The backend, on the other hand, recieves the error "ResetWithoutClosingHandshake".

So far, we have been unable to solve this issue, and the entire application is broken as a result. We have reviewed our codebase multiple times but either we are unable to find the bug, or this is not an issue on our part.

@wd7bxscience wd7bxscience added the bug Something isn't working label May 16, 2024
@wd7bxscience
Copy link
Collaborator Author

Let me explain.

React.js has a hook called useEffect(), which is designed to sync data from an external server and is ideal for connecting to a websocket.

useEffect() take two parameters. The first is the actual function that is maintained, and the second is an array (optional) that you input state that, if changed, should RE-RENDER. For example, say you want to store the data from a websocket as a state. You do NOT want it to RE-RENDER if you setState(), since it would CONTINUOUSLY RE-RENDER. This means, it would open a new websocket connection over, and over, and over again.

I am an idiot, and did not understand that if you don't pass the array, it forces React to make all the dependencies re-render. As a result, I removed the array in a previous commit, and things immediately failed as React opened a websocket over and over and over again.

By passing in the empty array, it signifies that you have no dependencies. This system is opt-out, not opt-in by default.

I apologize for overlooking such a critical error, and am glad that we can finally close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants