node-slack-sdk
node-slack-sdk copied to clipboard
SocketModeClient still fails to automatically reconnect when apps.connections.open API returns an error code
We recently upgraded @slack/socket-mode
to 1.3.1
to address https://github.com/slackapi/node-slack-sdk/issues/1495, but it seems there're still some unhandled scenarios where it wouldn't reconnect automatically.
This time the pattern is exactly the same as in https://github.com/slackapi/node-slack-sdk/issues/1495, but the error code is fatal_error
(vs internal_error
). Restarting the process fixed the issue. See the repro steps below with more logs.
Packages:
Select all that apply:
- [ ]
@slack/web-api
- [ ]
@slack/rtm-api
- [ ]
@slack/webhooks
- [ ]
@slack/oauth
- [x]
@slack/socket-mode
- [ ] I don't know
Reproducible in:
The Slack SDK version
any version including 1.3.1
Node.js runtime version
any
OS info
any
Steps to reproduce:
[INFO] A pong wasn't received from the server before the timeout of 5000ms!
[INFO] Reconnecting to Slack ...
[INFO] Going to establish a new connection to Slack ...
[ERROR] Failed to retrieve a new WSS URL for reconnection (error: Error: An API error occurred: fatal_error)
[WARNING] Failed to start a Socket Mode connection (error: An API error occurred: fatal_error)
And then endless loop of:
[ERROR] Failed to send a message as the client is not ready
[ERROR] An unhandled error occurred while Bolt processed (type: event_callback, error: Error: Failed to send a WebSocket message
Expected result:
The SocketModeClient automatically reconnects when the server-side started working again.
Actual result:
The reconnection does not happen.
@levenleven Thanks for sharing this. The situation where the server returns fatal_error is not a common situation and it is clearly an issue on the server side. As long as the error response continues, the Socket Mode client app is unable to automatically reconnect. I am not sure why restarting the client helps. I cannot tell when and how this can be improved yet but, once we get new information on this, our team will update you.
Hello, @seratch we've received a similar error but without (error: An API error occurred: fatal_error)
Error details: Error: Failed to send a WebSocket message as the client is not ready, retry num: undefined, retry reason: undefined
Could it have the same reason? Thank you.
I can validate this issue. Will send a PR with a test and a fix.