Commit e3822e2
authored
Fix: Disconnect before reconnecting to prevent duplication (#90)
In Automattic/simplenote-electron we noticed that after signing out of
the application and signing in again we were getting infinite
duplication of changes. This occurred until we quit the app and
restarted it.
We discovered that when signing back in the Simperium client library was
opening a new WebSocket connection without closing the old one. Whenever
the server sent back changes the client got them twice and tried to
update the content twice, which then cascaded duplication without end.
In this patch we're closing the existing connection if it's already open
when we call `connect()`. This probably fixes defects we haven't
associated with this change.1 parent d069594 commit e3822e2
3 files changed
+10
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
0 commit comments