This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
Ensure no reconnect happens after destroy() #434
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The purpose of this PR is to ensure if someone calls
destroy()
on their worker instance, it won't reconnect. Callingdestroy()
already cancels any pending reconnect attempts, but there's a small chance that thestart.rtm
api call was already issue, but hasn't received a response yet. In this case what happens is the worker closes out the current RTM connection and cancels any queued up reconnect attempts. It doesn't currently handle a case where the callback from thertm.started
api call comes back afterdestroy()
was called.I added a flag to track the state of if the worker has been destroyed - and then make sure to check that prior to creating the websocket connection for the RTM. This prevents the case described above.
We've run with this particular patch on a bot with about 60 teams connected and it's resolved issues they've had related to this bug (they would end up with 2 RTM connections to a team when trying to manually destroy a worker instance, and create a new one).