Skip to content

Commit

Permalink
Merge pull request #3063 from botpress/jhb-slack-unmount
Browse files Browse the repository at this point in the history
fix(slack): disconnect websocket onBotUnmount
  • Loading branch information
allardy committed Mar 10, 2020
2 parents 1a34bff + 221ca89 commit 0ea93f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions modules/channel-slack/src/backend/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export class SlackClient {
await this._setupRealtime()
}

async shutdown() {
if (this.rtm) {
await this.rtm.disconnect()
}
}

private async _setupInteractiveListener() {
this.interactive.action({ type: 'button' }, async payload => {
debugIncoming(`Received interactive message %o`, payload)
Expand Down
1 change: 1 addition & 0 deletions modules/channel-slack/src/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const onBotUnmount = async (bp: typeof sdk, botId: string) => {
return
}

await client.shutdown()
delete clients[botId]
}

Expand Down
4 changes: 3 additions & 1 deletion modules/channel-slack/src/backend/typings.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export type Clients = { [key: string]: any }
import { SlackClient } from './client'

export type Clients = { [key: string]: SlackClient }

0 comments on commit 0ea93f1

Please sign in to comment.