Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only re-prepare MatrixrRTC delayed disconnection event on 404 (#4575)
* Set retry counts of event updating to 1000 (from 1) With it being set to one the following issue could occur: ``` // If sending state cancels your own delayed state, prepare another delayed state // TODO: Remove this once MSC4140 is stable & doesn't cancel own delayed state if (this.disconnectDelayId !== undefined) { try { const knownDisconnectDelayId = this.disconnectDelayId; await resendIfRateLimited( () => this.client._unstable_updateDelayedEvent( knownDisconnectDelayId, UpdateDelayedEventAction.Restart, ), 1000, ); } catch (e) { logger.warn("Failed to update delayed disconnection event, prepare it again:", e); this.disconnectDelayId = undefined; await prepareDelayedDisconnection(); } } ``` This code looks like the `catch(e)` could never be triggered with 429 (rate limit) because they would be caught by `await resendIfRateLimited`. EXCEPT that this is only happening once: `resendIfRateLimited<T>(func: () => Promise<T>, numRetriesAllowed: number = 1)`. So as soon as the server sends two rate limits in a row we get the following: - we get into the `catch(e)` because of the rate limit - we forget about `this.disconnectDelayId = undefined` - we start a new delayed event `await prepareDelayedDisconnection();` - we do not anymore update the old delayed event which is still running! - the running delay event will make us disconnect from the call (call member becomes `{}`) - we get into our outher error catching mechanism that resends the new state event - this cancels the newly created delay leave event (`await prepareDelayedDisconnection();`) - and create another delay leave event. - but if we are still reate limited (chances are really high due to the reconnect), this loop will REPEAT * also check for M_NOT_FOUND * Leave retry at current level --------- Co-authored-by: Hugh Nimmo-Smith <[email protected]>
- Loading branch information