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

Prevent ws send() after hibernation #1005

Merged
merged 1 commit into from
Aug 10, 2023
Merged

Conversation

MellowYarker
Copy link
Contributor

If a client does not honor a close message sent from a DO, we will not receive a close from the client. We need to keep track of the fact the DO's websocket sent a close, otherwise we will allow the websocket to send() again once it wakes from hibernation.

IoOwn<WebSocket::Native> WebSocket::initNative(
IoContext& ioContext,
kj::WebSocket& ws,
bool closedOutgoingConn) {
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking Nit: generally not a fan of bool arguments. This one admittedly isn't too bad since the call site is not passing true or false but still, as a general rule I have a strong preference for using enum args or options structs here so that call sites are more self documenting...

e.g.

initNative(ct, ws, Options::CLOSED_OUTGOING_CONNECTION)

// as opposed to

initNative(ct, ws, true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but in this case there's only one call site and it's practically "moving" Native::closedOutgoing back into the api::WebSocket upon construction. If it were slightly more complicated I'd opt for the enum.

If a client does not honor a close message sent from a DO, we will not
receive a close from the client. We need to keep track of the fact the
DO's websocket sent a close, otherwise we will allow the websocket to
send() again once it wakes from hibernation.
Copy link
Contributor

@bcaimano bcaimano left a comment

Choose a reason for hiding this comment

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

Thanks for your work!

@MellowYarker MellowYarker merged commit 31a8b88 into main Aug 10, 2023
7 checks passed
@MellowYarker MellowYarker deleted the milan/hib-ws-close-update branch August 10, 2023 18:46
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.

3 participants