Listener middleware not called for catchAll listener
See original GitHub issueVersion
- 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:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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”?
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.