question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

receiverAckTimeoutError should not throw if authorization of incoming event fails

See original GitHub issue

Description

When an incoming event fails to authenticate via Bolt’s authorizeFn, the following warning is thrown:

https://github.com/slackapi/bolt/blob/227421b324bcf5548d1263db7b61fc66eb407908/src/App.ts#L395

Then, the following error is thrown that the incoming event is not acknowledged.

https://github.com/slackapi/bolt/blob/6cd88eb3a6246405dee9afe06f793ed7c59958f2/src/ExpressReceiver.ts#L75-L78

Is this the expected design? If listeners are not being called, why do we need to call ack()?

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: >= 1.2.0

node version: v12.12.0

OS version(s): macOS Catalina 10.15.1

Steps to reproduce:

  1. With authorizeFn, do not authorize an incoming event.

Expected result:

Incoming event is not sent to listeners. receiverAckTimeoutError is not thrown.

Actual result:

receiverAckTimeoutError is thrown.

Attachments:

   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR { Error: Authorization of incoming event did not succeed.
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR     at Object.errorWithCode (/home/vcap/deps/0/node_modules/@slack/bolt/dist/errors.js:17:19)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR     at authorizationErrorFromOriginal (/home/vcap/deps/0/node_modules/@slack/bolt/dist/App.js:293:28)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR     at authorizeResult.authorize.catch (/home/vcap/deps/0/node_modules/@slack/bolt/dist/App.js:145:32)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR     at process._tickCallback (internal/process/next_tick.js:68:7)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR   code: 'slack_bolt_authorization_error',
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR   original:
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR    Error: No matching authorizations for E27SFGS2W:T0258Q0SG
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at App.module.exports [as authorize] (/home/vcap/app/src/authorizeFn.js:15:15)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at App.onIncomingEvent (/home/vcap/deps/0/node_modules/@slack/bolt/dist/App.js:144:45)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at ExpressReceiver.App.receiver.on.message (/home/vcap/deps/0/node_modules/@slack/bolt/dist/App.js:55:53)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at ExpressReceiver.emit (events.js:198:13)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at ExpressReceiver.requestHandler (/home/vcap/deps/0/node_modules/@slack/bolt/dist/ExpressReceiver.js:70:14)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at Layer.handle [as handle_request] (/home/vcap/deps/0/node_modules/express/lib/router/layer.js:95:5)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at next (/home/vcap/deps/0/node_modules/express/lib/router/route.js:137:13)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at respondToUrlVerification (/home/vcap/deps/0/node_modules/@slack/bolt/dist/ExpressReceiver.js:122:5)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at Layer.handle [as handle_request] (/home/vcap/deps/0/node_modules/express/lib/router/layer.js:95:5)
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR        at next (/home/vcap/deps/0/node_modules/express/lib/router/route.js:137:13) }
   2020-01-02T15:25:13.64-0500 [APP/PROC/WEB/0] ERR [WARN]   Authorization of incoming event did not succeed. No listeners will be called.
   2020-01-02T15:25:16.44-0500 [APP/PROC/WEB/0] ERR { Error: An incoming event was not acknowledged before the timeout. Ensure that the ack() argument is called in your listeners.
   2020-01-02T15:25:16.44-0500 [APP/PROC/WEB/0] ERR     at receiverAckTimeoutError (/home/vcap/deps/0/node_modules/@slack/bolt/dist/ExpressReceiver.js:213:19)
   2020-01-02T15:25:16.44-0500 [APP/PROC/WEB/0] ERR     at Timeout.setTimeout [as _onTimeout] (/home/vcap/deps/0/node_modules/@slack/bolt/dist/ExpressReceiver.js:39:32)
   2020-01-02T15:25:16.44-0500 [APP/PROC/WEB/0] ERR     at ontimeout (timers.js:436:11)
   2020-01-02T15:25:16.44-0500 [APP/PROC/WEB/0] ERR     at tryOnTimeout (timers.js:300:5)
   2020-01-02T15:25:16.44-0500 [APP/PROC/WEB/0] ERR     at listOnTimeout (timers.js:263:5)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
barlockcommented, Jan 3, 2020

@aoberoi ☝️ This is a really good example of why I think App.processEvent in the proposal https://github.com/slackapi/bolt/issues/353#issuecomment-570650203 should reject with an error.

0reactions
seratchcommented, Aug 26, 2021

I’ve confirmed that #891 can resolve this issue.

import { App, ExpressReceiver } from '@slack/bolt';
const app = new App({
  receiver: new ExpressReceiver({
    signingSecret: process.env.SLACK_SIGNING_SECRET!!,
  }),
  authorize: async (_) => { throw new Error("Failed!"); }
});

The above example app returns 401 HTTP status and shows the following logs only:

[WARN]  bolt-app Authorization of incoming event did not succeed. No listeners will be called.
[ERROR]  bolt-app Error: Failed!
    at /Users/ksera/github/bolt-js/examples/getting-started-typescript/dist/app.js:25:15
    at Generator.next (<anonymous>)
    at /Users/ksera/github/bolt-js/examples/getting-started-typescript/dist/app.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/ksera/github/bolt-js/examples/getting-started-typescript/dist/app.js:4:12)
    at App.authorize (/Users/ksera/github/bolt-js/examples/getting-started-typescript/dist/app.js:24:23)
    at App.processEvent (/Users/ksera/github/bolt-js/dist/App.js:375:46)
    at ExpressReceiver.requestHandler (/Users/ksera/github/bolt-js/dist/receivers/ExpressReceiver.js:154:77)
    at Layer.handle [as handle_request] (/Users/ksera/github/bolt-js/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/ksera/github/bolt-js/node_modules/express/lib/router/route.js:137:13) {
  code: 'slack_bolt_authorization_error'
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

receiverAckTimeoutError should not throw if authorization of ...
Description. When an incoming event fails to authenticate via Bolt's authorizeFn , the following warning is thrown: https://github.com/slackapi/ ...
Read more >
Bolt for JavaScript - Slack Platform Developer Tools
If the incoming request is not authorized or you're calling a method from outside of a listener, use the top-level app.client .
Read more >
A Definitive Guide to Handling Errors in JavaScript - Kinsta
This error occurs when you try to invoke a method that doesn't exist in your script, or it does but can not be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found