Skip to content

Commit

Permalink
Merge pull request #91 from funidata/bugfix/issue-73/fix-socketmode-d…
Browse files Browse the repository at this point in the history
…isconnects

remove outdated workaround
  • Loading branch information
joonashak authored Jul 21, 2023
2 parents 9eab985 + 5c4dfd9 commit f31476d
Showing 1 changed file with 21 additions and 34 deletions.
55 changes: 21 additions & 34 deletions app/src/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
require('./tools/timestampedLogger').replaceLoggers();
require('dotenv').config();
require('./tools/quotenv').checkEnv([
'SLACK_BOT_TOKEN',
'SLACK_APP_TOKEN',
'SLACK_SIGNING_SECRET',
]);
const { App } = require('@slack/bolt');
const scheduler = require('./scheduler/scheduler');
const usergroups = require('./usergroups');
const { enableActionFunctions } = require('./actionFunctions');
const { enableEventListeners } = require('./eventListeners');
const { enableUserCache } = require('./userCache');
const { enableMiddleware } = require('./middleware');
const { enableSlashCommands } = require('./slashCommands');
require("./tools/timestampedLogger").replaceLoggers();
require("dotenv").config();
require("./tools/quotenv").checkEnv(["SLACK_BOT_TOKEN", "SLACK_APP_TOKEN", "SLACK_SIGNING_SECRET"]);
const { App } = require("@slack/bolt");
const scheduler = require("./scheduler/scheduler");
const usergroups = require("./usergroups");
const { enableActionFunctions } = require("./actionFunctions");
const { enableEventListeners } = require("./eventListeners");
const { enableUserCache } = require("./userCache");
const { enableMiddleware } = require("./middleware");
const { enableSlashCommands } = require("./slashCommands");

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

const state = {
app,
usergroups,
app,
usergroups,
};

const userCache = enableUserCache(state);
Expand All @@ -38,17 +34,8 @@ enableSlashCommands(state);
* Starts the bot.
*/
(async () => {
await app.start();
scheduler.startScheduling(state);
scheduler.scheduleUsergroupReadings(state);
console.log('⚡️ Bolt app is running!');
await app.start();
scheduler.startScheduling(state);
scheduler.scheduleUsergroupReadings(state);
console.log("⚡️ Bolt app is running!");
})();

/**
* Workaround so Node 14.x doesn't crash if our WebSocket disconnects and Bolt doesn't reconnect.
* See https://github.com/slackapi/node-slack-sdk/issues/1243.
* We could specify node 16.x in our Dockerfile which would make that a crashing error.
*/
process.on('unhandledRejection', (error) => {
throw error;
});

0 comments on commit f31476d

Please sign in to comment.