slackapi/bolt-js

Frequent disconnects in socket mode

Closed this issue ยท 9 comments

(Filling out the following with as much detail as you can provide will help us solve your issue sooner.)

@slack/bolt

3.18.0

const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
socketMode: true,
appToken: process.env.SLACK_APP_TOKEN
});

Node.js runtime version

20.11.1

Steps to reproduce:

(Share the commands to run, source code, and project settings)

  1. Start server according to example docs
  2. Server receives events just fine...for a while
  3. Server disconnects with error

Expected result:

Server stays connected indefinitely

Actual result:

StateMachine.js:76
throw new Error('Unhandled event '' + event + '' in state '' + this.currentState + ''.');
^

Error: Unhandled event 'server explicit disconnect' in state 'connecting'.
at StateMachine.handleUnhandledEvent (.../node_modules/finity/lib/core/StateMachine.js:76:13)
at .../node_modules/finity/lib/core/HierarchicalStateMachine.js:79:33

Hi, @stephenkalnoske-sans! Thank you for submitting this issue! ๐Ÿ™‡

To be able to better understand the issue - how often does this occur? Are you noticing a maximum threshold of time that the connection lasts before you receive this error?

Hi @hello-ashleyintech! I haven't been able to pinpoint exactly when this occurs. But it is daily. I'll start the service in the morning and by the end of the day it is disconnected with that error.

Looks like the same issue as this one in the underlying socket mode package: slackapi/node-slack-sdk#1787

@stephenkalnoske-sans can you confirm the exact version of @slack/socket-mode you are using in your bolt app? It is a dependency of bolt, you can check it by running npm ls | grep socket-mode.

Yep! v1.3.5

Has this been happening more recently? I'm trying to identify where this issue was introduced, whether it is new or whether this behaviour has always existed.

Do you see it if you lock socket-mode to v1.3.4?
Another alternative is to try @slack/bolt@4.0.0-rc.1, which uses the new socket-mode 2.0, which ditches the 1.x line of socket mode (which used a problematic design of 2 alternating socket connections pumping transitions into a single state machine).

@filmaj I only installed bolt last week so didn't have any other releases but the most current one. I have the 4.0 release candidate running now and will watch it to see if I get any more disconnects. Previously it would happen every day so will know soon. Thanks for your help!

Awesome, please feel free to at-mention me with any issues that crop up. Appreciate any feedback you provide on the release candidate!

Hi @filmaj, definitely seems more stable now. I'll close this out. RC1 is running fine as well. Thanks again!

Ok sounds good! I'd recommend you lock to rc1 (and not allow for floating versions via ~ or ^) as rc2 and so on may introduce breaking changes as we inch closer to a brand new bolt v4 major version.