Make sure Accounts login only sets 1 onReconnect callback #9148
The changes added in d854a4b fixed a long standing issue where the Accounts system was overwriting other DDP
The changes in this commit make sure that any previously set Accounts login
The changes added in d854a4b fixed a long standing issue where the Accounts system was overwriting other DDP `connection.onReconnect` callbacks, that were potentially set by developers (and vice-versa - developers could overwrite the `onReconnect` callback registered by the Accounts system, which impacted logging back in after reconnecting). Unfortunately these changes are also registering a new duplicate `onReconnect` callback to be called, after every login. These duplicate callbacks pile up and are all called when reconnecting, which eventually breaks user logins. The changes in this commit make sure that any previously set Accounts login `onReconnect` callback is first removed, before adding a new callback. This ensures the Accounts system is only ever setting one `onReconnect` callback after logging in. Fixes #9140.
* Fix bug #5665: add DDP.onReconnect(), deprecate conn.onReconnect Deprecate use of `connection.onReconnect = func`. Instead, a new `DDP.onReconnect(callback)` method should be used to register callbacks to call when a connection reconnects. The connection that is reconnecting is passed as the only argument to `callback`. This is used by the accounts system to relogin on reconnects without interfering with other code which uses `connection.onReconnect`. * Adjust History entry, package versions, code cleanup
Just confirming that the tests for the merge commit (01b5487) and passed
Thanks so much for the fix and amended test, @hwillson!