From 4e9ff3cb8f9266c4d2d24c77fc48cd2663e160b5 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Fri, 17 Jul 2020 20:07:32 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=86=8D=E8=A9=A6=E8=A1=8C=E6=8A=91?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 926a767..c2a6f75 100644 --- a/app.js +++ b/app.js @@ -1,10 +1,30 @@ -const { App } = require("@slack/bolt"); +const { promisify } = require("util"); +const { App, ExpressReceiver } = require("@slack/bolt"); const daraz = require("./"); +class Receiver extends ExpressReceiver { + /** + * @param {import("express").Request} req + * @param {import("express").Response} res + */ + requestHandler(req, res) { + // NOTE: See also https://api.slack.com/events-api#errors + res.header("x-slack-no-retry", "1"); + if (req.headers["x-slack-retry-reason"] === "http_timeout") + return promisify(res.end)(); + + return super.requestHandler(req, res); + } +} + +const receiver = new Receiver({ + signingSecret: process.env.SLACK_SIGNING_SECRET, +}); + const app = daraz( new App({ token: process.env.SLACK_BOT_TOKEN, - signingSecret: process.env.SLACK_SIGNING_SECRET, + receiver, }) );