Bolt-js: Initialization includes unhandled async request

Created on 11 Sep 2019  路  6Comments  路  Source: slackapi/bolt-js

Description

On initializing an App, it appears a call to the API test endpoint is made but the response is not being handled appropriately.

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

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

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

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

Bug Report

Creating an app with bad credentials results in an UnhandledPromiseRejectionWarning.

Reproducible in:

package version: *

node version: *

OS version(s): *

Steps to reproduce:

const Bolt = require('@slack/bolt');
let app = new Bolt.App({
    signingSecret: 'JUNK',
    token: 'JUNK',
    logLevel: Bolt.LogLevel.DEBUG
});

Expected result:

The app should handle the failed response and then throw an appropriate error when used after the faulty initialization.

_In my opinion, this auth test call shouldn't be a part of the initialization, but I can see why y'all would add it._

Actual result:

The app initializes and an UnhandledPromiseRejectionWarning occurs

Additional Info

Here are the logs for the above snippet:

> const Bolt = require('@slack/bolt');
undefined
> let app = new Bolt.App({
...     signingSecret: 'JUNK',
...     token: 'JUNK',
...     logLevel: Bolt.LogLevel.DEBUG
... });
[DEBUG]  WebClient:0 initialized
[DEBUG]  WebClient:0 apiCall('auth.test') start
[DEBUG]  WebClient:0 will perform http request
undefined
> [DEBUG]  WebClient:0 http response received
(node:50240) UnhandledPromiseRejectionWarning: Error: An API error occurred: invalid_auth
    at Object.platformErrorFromResult (.../node_modules/@slack/web-api/dist/errors.js:50:33)
    at WebClient.apiCall (.../node_modules/@slack/web-api/dist/WebClient.js:382:28)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:50240) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:50240) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
bug

Most helpful comment

I can reproduce this. It looks like there's a bug with our SingleTeamAuthorization function that should be fixed to handle these error responses correctly. Both the users.info and auth.test calls in that method aren't being properly handled.

All 6 comments

I can reproduce this. It looks like there's a bug with our SingleTeamAuthorization function that should be fixed to handle these error responses correctly. Both the users.info and auth.test calls in that method aren't being properly handled.

@shaydewael @seratch @aoberoi any update on this? No rush, just curious.

The only reason it's an issue is it can sometimes mask/muddle other problems like this one (see the comment at the bottom of the issue).

馃憢 Hey there, thanks for checking in. We haven't started working on this yet, but I agree that it should be a relatively high priority to get this bug out of your way. I'm adding it to our project board now.

@aoberoi we ended up fixing it on our end just by making the Slack init something we wait for instead of having it just start and assuming it'll work.

We realized that that pattern was introducing other problems too, so I'm glad we refactored to fix it.

I'd still love to see this handled in some way so I could chose to ignore the error.

@SpencerKaiser Having the similar issue, have any code to share your fix? I'm just looking to verify tokens before discarding the App.

@DanielTamkin we have a decent workaround, but still not great.

Was this page helpful?
0 / 5 - 0 ratings