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.

Global Middleware not respecting next()

See original GitHub issue

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
  • 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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
seratchcommented, Feb 7, 2020
2reactions
artgillespiecommented, Feb 4, 2020

👋 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
})


Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Middleware - Next.js
Middleware allows you to run code before a request is completed, then based on the incoming request, you can modify the response by...
Read more >
express global middleware not being called - node.js
I expect to see "inside middleware", then "inside route". Instead, I just see "inside route". is specific to error handling middleware.
Read more >
Using middleware - Express.js
If the current middleware function does not end the request-response cycle, it must call next() to pass control to the next middleware function....
Read more >
Middleware - Laravel - The PHP Framework For Web Artisans
The withoutMiddleware method can only remove route middleware and does not apply to global middleware. Middleware Groups. Sometimes you may want to group ......
Read more >
Middleware | NestJS - A progressive Node.js framework
if the current middleware function does not end the request-response cycle, it must call next() to pass control to the next middleware function....
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