-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-fix #395 by adjusting the processBeforeResponse option #459
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,12 +96,24 @@ export default class ExpressReceiver implements Receiver { | |
|
||
try { | ||
await this.bolt?.processEvent(event); | ||
if (storedResponse !== undefined) { | ||
if (typeof storedResponse === 'string') { | ||
res.send(storedResponse); | ||
} else { | ||
res.json(storedResponse); | ||
|
||
if (this.processBeforeResponse) { | ||
let spentMillis = 0; | ||
const millisForTimeout = 10; | ||
// Wait here until the isAcknowledged is marked as true or 3 seconds have passed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is not ideal but I haven't figured out any other solutions yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused by this. Can you explain the error use case you are fixing here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stevengill
The change here is addressing This fix surely holds off responding until verifying the acknowledgment on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One additional note: I've added a unit test verifying |
||
while (!isAcknowledged && spentMillis < 3000) { | ||
await new Promise(resolve => setTimeout(resolve, millisForTimeout)); | ||
spentMillis += millisForTimeout; | ||
} | ||
if (isAcknowledged) { | ||
this.logger.debug(`The listener execution completed in ${spentMillis} millis`); | ||
if (typeof storedResponse === 'string') { | ||
res.send(storedResponse); | ||
} else { | ||
res.json(storedResponse); | ||
} | ||
this.logger.debug('Acknowledged after the listener completion'); | ||
} // Otherwise, this Bolt app never responds to this request and above setTimeout outputs an error message | ||
} | ||
} catch (err) { | ||
res.send(500); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice Fix!