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.

Listener middleware not called for catchAll listener

See original GitHub issue

Version

  • hubot@2.19.0

Problem

Hubot supports populating contents in message object through middlewares, but it seems the contents are lost in catchAll handler.

Reproduce Steps

scripts/example.coffee:

# Description:
#   Test listener and catchAll.
# 
module.exports = (robot) ->
  robot.catchAll (res) ->
    res.reply res.message.secret
  robot.respond /test/, (res) ->
    res.reply res.message.secret
  robot.listenerMiddleware (context, next, done) ->
    context.response.message.secret = 'hello'
    next()

Testing

C:\Users\rophy\git\hubot-secret>bin\hubot
up to date in 1.074s
hubot-secret> hubot-secret test
hubot-secret> Shell: hello
hubot-secret> hubot-secret abcabc
hubot-secret> Shell: undefined

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
timkinnanecommented, Jun 30, 2017

Good stuff. Well this tickets original question is answered, but if we’re keeping it open to resolve the bug it’s raised, can we modify the title to something like “Listener middleware not called for catchAll listener”?

2reactions
timkinnanecommented, Jun 28, 2017

OK actually I think I know why this isn’t working anyway. From the docs: “Listener middleware inserts logic between the listener matching a message and the listener executing” - catch all fires when no listeners match, so the listener middleware would never be called in this case. You should try it with robot.receiveMiddleware instead.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redux Toolkit's new listener middleware vs. Redux-Saga
In this article, I will compare the new listener middleware with Redux-Saga and highlight some of the cross-cutting features.
Read more >
createListenerMiddleware - Redux Toolkit - JS.ORG
Listeners can be defined statically by calling listenerMiddleware. ... The instance object is not the actual Redux middleware itself.
Read more >
Socket.io Client: respond to all events with one handler?
With the following code you have two new functions to: Trap all events; Trap only events which are not trapped by the old...
Read more >
A Guide to Error Handling in Express.js | Scout APM Blog
Error handling often doesn't get the attention it deserves. Mishandled errors can lead to a bad UX and negatively affect your business.
Read more >
Client API - Socket.IO
Returns the array of listeners for the event named eventName . socket.on("my-event", ...
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