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

Asynchronous Client: Unexpected Server disconnect leads to panic #323

Closed
sirkrypt0 opened this issue Jun 2, 2023 · 0 comments · Fixed by #324
Closed

Asynchronous Client: Unexpected Server disconnect leads to panic #323

sirkrypt0 opened this issue Jun 2, 2023 · 0 comments · Fixed by #324

Comments

@sirkrypt0
Copy link
Contributor

Problem Description

In #314 the stream implementation of the asynchronous socket has been adjusted.
However, when the server now disconnects unexpectedly (e.g. process is killed etc.), the following issue can now be observed:

thread 'tokio-runtime-worker' panicked at 'Unfold must not be polled after it returned `Poll::Ready(None)`'

Steps To Reproduce

  1. Use client and server from Asynchronous Client: "Error while parsing an incomplete packet socketio" on first heartbeat killing the connection #311
  2. Start the server and then the client
  3. Stop the server
  4. Observe the panic in the client

Possible Solution

The loop which polls the stream in the asynchronous client builder needs to stop when the stream returns None:

loop {
// tries to restart a poll cycle whenever a 'normal' error occurs,
// it just logs on network errors, in case the poll cycle returned
// `Result::Ok`, the server receives a close frame so it's safe to
// terminate
if let Some(e @ Err(Error::IncompleteResponseFromEngineIo(_))) = stream.next().await
{
trace!("Network error occured: {}", e.unwrap_err());
}
}

Apparently, this issue existed before #314 already.
However, due to the different stream implementation, calls to stream.next() after the stream has terminated wouldn't panic but instead always return None leading to an infinite loop.
The issue only now surfaced because of the different stream implementation.

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 a pull request may close this issue.

1 participant