Fix #1495 SocketModeClient still fails to automatically reconnect when apps.connections.open API returns an error code#1496
Merged
seratch merged 1 commit intoslackapi:mainfrom Jun 14, 2022
Conversation
…nect when apps.connections.open API returns an error code
mwbrooks
approved these changes
Jun 13, 2022
Member
mwbrooks
left a comment
There was a problem hiding this comment.
Thanks for continuing to harden the Socket Mode package!
Is this a new, recent error or one that has existed for a while but we've only become aware of?
[ERROR] Failed to retrieve a new WSS URL for reconnection (error: Error: An API error occurred: internal_error)
Contributor
Author
@mwbrooks This is not a new but a rare pattern. Except the ones listed in the "unrecoverable" error code list, the rest should be retried but the state machine is not working in the way at least with the current code. |
filmaj
approved these changes
Jun 13, 2022
Contributor
filmaj
left a comment
There was a problem hiding this comment.
LGTM! I like the split between groups of states 👍 ![]()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This pull request resolves #1495 .
To test the behavior, you can modify
retrieveWSSURLmethod as below plus runcd examples && ./link.sh && npm startto see how it works:The direct cause of the reconnection failure was that there is no logic to handle
connecting:reconnectingin the current code. When you use a sub state machine in this state machine library, it has a state hierarchy and your code needs to have the comprehensive set of handlers for all the state sets.To prevent this type of coding error happening again in the future (actually, this pattern errors existed much more before 1.3.0 release), I've added enums for the sub state machines - ConnectingState and ConnectedState. With these, passing a state to a sub machine is type-safe. Passing the top-level State enum to a sub state machine does not compile anymore.
Requirements (place an
xin each[ ])