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(websocket): use binary operations instead of a Set for closeStatus #3635

Closed
wants to merge 3 commits into from

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Sep 21, 2024

Follow up to #3628

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

It's possible to avoid the set but nothing here is a hot path - websockets are not closed often.

It's not worth the mental overhead. The websocket closing handshake is an extremely cold path.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 21, 2024

Using a Set is an unconventional and to honest very ugly Implementation in our codebase. I strongly recommend to avoid ES6 Sets to just store 2 bit information...

@KhafraDev
Copy link
Member

I don't agree with any of that. The implementation is easy to understand and not in a critical path. Those paths are triggered when

  • manually closing (WebSocket.prototype.close)
  • receiving a close frame

You can only close a websocket once per instance, and websockets are rarely closed by nature. Not only that, NOT_SENT is an illogical name for a state because the closing handshake starts when sending or receiving a close frame.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 26, 2024

@KhafraDev

What if rename it to NONE?

@Uzlopak Uzlopak closed this Oct 7, 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.

2 participants