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

server: graceful shutdown check Incoming::Closed #1216

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

niklasad1
Copy link
Member

No description provided.

@niklasad1 niklasad1 requested a review from a team as a code owner October 13, 2023 10:50
@niklasad1 niklasad1 force-pushed the na-graceful-shutdown-check-incoming-closed branch from 8743ed1 to 53b882b Compare October 13, 2023 12:03
server/src/transport/ws.rs Outdated Show resolved Hide resolved
match receiver.receive(&mut data).await {
Ok(Incoming::Closed(_)) | Err(SokettoError::Closed) => None,
Ok(Incoming::Data(_) | Incoming::Pong(_)) => Some(((), (receiver, data))),
Err(e) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to check; do you no longer need to return None when Err(SokettoError::Closed) is a thing now?

Copy link
Member Author

@niklasad1 niklasad1 Oct 16, 2023

Choose a reason for hiding this comment

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

All errors except Closed are ignored here because we can't really know whether when it's closed or not otherwise.

We will keep the stream alive until either SokettoError::Closed or Incoming::Closed is returned back because some implementations may not do the proper WebSocket close handshake message such as the soketto client #871. Thus, we need to check both

However, soketto will eventually return SokettError::Closed after this https://github.com/paritytech/soketto/blob/master/src/connection.rs#L386-L388 so this extra check in this PR shouldn't matter in "practice" but we need to call receive one more time instead then also I like us to be explicit here which makes it easier to understand.

FWIW, it may also be a bunch of I/O errors that could terminate the connection as well but those are super-tricky to detect so we are relying on the close stuff... and that soketto regards EOF errors as Closed

Copy link
Collaborator

@jsdw jsdw Oct 16, 2023

Choose a reason for hiding this comment

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

Oohh I actually missed that you were still paying attention to SokettoError::Closed anyway, so yup all makes sense to me now; thanks for the explanation! :)

@niklasad1 niklasad1 merged commit 00a654f into master Oct 16, 2023
15 checks passed
@niklasad1 niklasad1 deleted the na-graceful-shutdown-check-incoming-closed branch October 16, 2023 11:23
niklasad1 added a commit that referenced this pull request Oct 24, 2023
* server: graceful shutdown check `Incoming::Closed`

* Update server/src/transport/ws.rs
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