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

Do not silently discard undelivered messages #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jsmucr
Copy link

@jsmucr jsmucr commented Nov 28, 2017

The plugin no longer discards messages which it fails to send if the server disconnects and sends some content prior to the disconnection.

Example situation before the fix:

  1. A connection is established between a server and the plugin.
  2. The plugin delivers some messages to the server.
    2.1) It may or may not read something that it received from the server.
    2.2) It sends the payload to the server.
  3. The server sends some content back and disconnects.
  4. The plugin tries to deliver some other messages to the server.
    4.1) It tries to read (if r.any?) and expects to get an EOFError in case the server just died.
    4.2) No error is thrown as some content just arrived from the server. It is discarded.
    4.3) The first payload is written to the socket, no error being thrown.
    4.4) The next payload finally fails with EOFError upon reading from the socket and an retry follows.

This commit fixes the 4.1 and 4.2 phases. The reading is now performed repeatedly while there's still something to read left so that we don't miss the EOFError exception.

The plugin no longer discards messages which it fails to send if the server disconnects and sends some content prior to the disconnection.

Example situation before the fix:

1. A connection is established between a server and the plugin.
2. The plugin delivers some messages to the server.
  2.1) It may or may not read something that it received from the server.
  2.2) It sends the payload to the server.
3. The server sends some content back and disconnects.
4. The plugin tries to deliver some other messages to the server.
  4.1) It tries to read (if r.any?) and expects to get an EOFError in case the server just died.
  4.2) No error is thrown as some content just arrived from the server. It is discarded.
  4.3) The first payload is written to the socket, no error being thrown.
  4.4) The next payload finally fails with EOFError upon reading from the socket and an retry follows.

This commit fixes the 4.1 and 4.2 phases. The reading is now performed repeatedly while there's still something to read left so that we don't miss the EOFError exception.
@yuri1969
Copy link

yuri1969 commented Feb 3, 2020

@jsvd, @ph, @danhermann is it possible to get an update on this? The v6.0.0 still silently drops the first message after a reconnect.

@cla-checker-service
Copy link

cla-checker-service bot commented Sep 4, 2020

💚 CLA has been signed

@jsmucr jsmucr force-pushed the patch-1 branch 4 times, most recently from 9f09957 to 7246be9 Compare September 4, 2020 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants