Bolt-js: Global Middleware not respecting next()

Created on 21 Dec 2019  路  5Comments  路  Source: slackapi/bolt-js

Description

Applying global middleware via app.use seems to pass control to the next part of the chain before next() is called.

Example:

module.exports = function(app) {
  app.use(function(payload, user){
    console.log('This comment should print and then timeout')
  })
  app.command("/pilot", slashCommand);
};

This should fail however control seems to pass correctly to the command. What am I missing?

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

  • [ ] bug
  • [x] enhancement (feature request)
  • [x] 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

Most helpful comment

All 5 comments

Hi @jamesfmac, thanks for reporting! I agree that the behavior seems wrong and I was able to reproduce this issue.

Here's the app I reproduced the issue in: https://codesandbox.io/s/slack-bolt-issue-355-pnr91

Thanks @aoberoi I thought I was going crazy :)

I got the same issue. Can鈥檛 ensure persisting a db model before message listener runs.

:wave: I've submitted a PR (#394) with a test case for this issue and a proposed fix.

In the meantime, since only the _last_ global middleware exhibits this behavior, a simple workaround is to add a no-op global middleware after all other global middleware. (This workaround also addresses the issue with async conversation stores)

app.use(() => {
  // no-op global middleware
})


Was this page helpful?
0 / 5 - 0 ratings