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?
x in one of the [ ])x in each of the [ ])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
})
Most helpful comment