papercups-io / papercups

Open-source live customer chat
https://app.papercups.io/demo
MIT License
5.77k stars 525 forks source link

Adds better error reporting when socket errors and try to reconnect #792

Closed rhonsby closed 3 years ago

rhonsby commented 3 years ago

Description

When the socket used for managing conversations errors out, we currently only log an error message. This commit logs the error as well to provide more visibility into why it's erroring and attempts to reconnect when it does error.

Issue

https://github.com/papercups-io/papercups/issues/774

Checklist

reichert621 commented 3 years ago

@rhonsby just curious, were you able to see if the reconnecting logic fixes anything when the socket gets disconnected (e.g. after the computer goes to sleep and gets reopened)?

rhonsby commented 3 years ago

@reichert621 I couldn't get the socket to disconnect with a short-ish sleep, so I'm going to try to let it sleep over lunch. I tested it another way that I thought would be similar:

  1. Load the page and verify in the console that you're connected.
  2. Try sending a message and verify that it works.
  3. Force stop your server and observe that the socket error handler is triggered.
  4. Try sending a message and verify that it doesn't work.
  5. Restart your server, but make sure you click the stop button on the browser to keep the page from refreshing.
  6. Observe that you reconnect back (via console messages and trying to send a message).

Update: I was able to repro the issue. It looks like this doesn't actually solve that case. Let me try to take a stab at that before merging this in.