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

call() method times out when connection/namespace is disconnected before result is sent. #813

Closed
kristjanvalur opened this issue Oct 26, 2021 · 4 comments
Assignees

Comments

@kristjanvalur
Copy link

kristjanvalur commented Oct 26, 2021

Describe the bug
This may or may not be a bug. Perhaps it is "as designed", In which case, please feel free to ignore :)

The following interaction has been observed using the AsyncClient:

  1. Client connects to a namespace.
  2. Client gets an on_connect event. The handler makes a call("hello") to the server and waits for a result
  3. Server gets on_hello event.
  4. server both emits a emit("failure") message to the client and returns "failure" (*)
  5. client receives on_failure event and performs an sio.disconnect() call, disconnecting all namespaces.
  6. Meanwhile step 2, from a above, is still waiting for the result from step 4.
  7. After 60 seconds, a TimeoutError is raised.

Expected behavior
I would expect step 7 above to result in an immediate "Client is disconnect" exception to be raised on the connection.

Additional context

(*) the reason I'm both emitting an event and returning a value, is that I'm trying to migrate from naked events into an rpc-like architecture. Older clients will be listening for the "failure" event, newer clients will be waiting for a response from the call()

@miguelgrinberg
Copy link
Owner

Yeah, this is really working in the way it was designed. The call() method just waits for the callback to arrive. If you disconnect, then the callback packet will never arrive. The correct response in this case is to issue the timeout when the 60 seconds (or whatever timeout you specified) have passed.

@kristjanvalur
Copy link
Author

kristjanvalur commented Oct 26, 2021 via email

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Oct 26, 2021

It is certainly possible to implement what you are suggesting, but I see this as a rare corner case. I would be making the code more complex and harder to maintain and test just to support a workflow that 99.9% of users will never encounter, and for the 0.1% that do, nothing is really broken and the function still works as advertised.

If you'd like to propose an improvement to the documentation I'm open to that.

@kristjanvalur
Copy link
Author

kristjanvalur commented Oct 26, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants