Description
Hi There,
Not really a Bolt-js issue, more an unexpected behavior and bad code from the net. You can close this issue when you want.
It took me quite some time to figure what was happening, so I'm posting it there if anyone run into the same kind of issue.
Problem:
- calling a command
/hello a first time works
- calling the same command a second time ... timeout and
/hello failed with the error "operation_timeout"
- the server log only show one line, pointing to a ack() issue
[ERROR] An incoming event was not acknowledged within 3 seconds. Ensure that the ack() argument is called in a listener.
- after waiting a bit, I can run the command again, but only once
- if I run another command, it works once, then timeout too
- when it timeout, it doesnt even reach my listener or any part of my bolt code
app.command(/(\/hello-dev|\/hello)/g, async ({ command, ack, respond }) => {
await ack()
await sayHello(command, respond)
})
Solution:
After debugging all over bolt and expressReceiver, I figured that the culprit is around here
The command regexp is tested with return pattern.test(candidate); and any flag immediately become problematic.
My bad for copying a bad regexp from a bolt tutorial without noticing that.
So changing the regexp suddenly solved the problem (getting rid of flags like /g, /y)
app.command(/^\/(hello-dev|hello).*/, async ({ command, ack, respond }) => {
await ack()
await sayHello(command, respond)
})
Idea for improvement:
- a warning message if not a single listener match, it would be way more helpful than a timeout
- not showing a warning related to ack() if not a single listener match
- a check on
.lastIndex or .flags to check that regexp are not carrying a state over queries
What type of issue is this? (place an x in one of the [ ])
Requirements (place an x in each of the [ ])
Description
Hi There,
Not really a Bolt-js issue, more an unexpected behavior and bad code from the net. You can close this issue when you want.
It took me quite some time to figure what was happening, so I'm posting it there if anyone run into the same kind of issue.
Problem:
/helloa first time works/hello failed with the error "operation_timeout"[ERROR] An incoming event was not acknowledged within 3 seconds. Ensure that the ack() argument is called in a listener.Solution:
After debugging all over bolt and expressReceiver, I figured that the culprit is around here
The command regexp is tested with
return pattern.test(candidate);and any flag immediately become problematic.My bad for copying a bad regexp from a bolt tutorial without noticing that.
So changing the regexp suddenly solved the problem (getting rid of flags like
/g,/y)Idea for improvement:
.lastIndexor.flagsto check that regexp are not carrying a state over queriesWhat type of issue is this? (place an
xin one of the[ ])Requirements (place an
xin each of the[ ])