Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed #1156, socketMode error not being properly thrown #1161

Merged
merged 2 commits into from Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/socket-mode/package.json
Expand Up @@ -44,8 +44,8 @@
"watch": "npx nodemon --watch 'src' --ext 'ts' --exec npm run build"
},
"dependencies": {
"@slack/logger": "^2.0.0",
"@slack/web-api": "^5.14.0",
"@slack/logger": "^3.0.0",
"@slack/web-api": "^6.0.0",
"@types/node": ">=12.0.0",
"@types/p-queue": "^2.3.2",
"@types/ws": "^7.2.5",
Expand Down
13 changes: 6 additions & 7 deletions packages/socket-mode/src/SocketModeClient.ts
Expand Up @@ -66,23 +66,22 @@ export class SocketModeClient extends EventEmitter {
.submachine(Finity.configure()
.initialState('authenticating')
.do(() => {
// TODO: change this to webClient.apps.connections.open()
return this.webClient.apiCall('apps.connections.open').then((result: WebAPICallResult) => {
return this.webClient.apps.connections.open().then((result: WebAPICallResult) => {
return result;
}).catch((error) => {
this.logger.error(error);
// throw error;
return Promise.reject(error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});
})
.onSuccess().transitionTo('authenticated')
.onFailure()
.transitionTo('reconnecting').withCondition((context) => {
const error = context.error as WebAPICallError;
this.logger.info('here');
this.logger.info(`unable to Socket Mode start: ${error.message}`);

// Observe this event when the error which causes reconnecting or disconnecting is meaningful
this.emit('unable_to_socket_mode_start', error);

let isRecoverable = true;
if (error.code === APICallErrorCode.PlatformError &&
(Object.values(UnrecoverableSocketModeStartError) as string[]).includes(error.data.error)) {
Expand Down Expand Up @@ -155,18 +154,18 @@ export class SocketModeClient extends EventEmitter {
.submachine(Finity.configure()
.initialState('authenticating')
.do(() => {
// TODO: change this to webClient.apps.connections.open()
return this.webClient.apiCall('apps.connections.open').then((result: WebAPICallResult) => {
return this.webClient.apps.connections.open().then((result: WebAPICallResult) => {
return result;
}).catch((error) => {
this.logger.error(error);
// throw error;
return Promise.reject(error);
});
})
.onSuccess().transitionTo('authenticated')
.onFailure()
.transitionTo('authenticating').withCondition((context) => {
const error = context.error as WebAPICallError;
this.logger.info('here');
this.logger.info(`unable to Socket Mode start: ${error.message}`);

// Observe this event when the error which causes reconnecting or disconnecting is meaningful
Expand Down