-
Notifications
You must be signed in to change notification settings - Fork 395
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
feat: expose auto acknowledgement flag on the function handler #2334
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2334 +/- ##
==========================================
- Coverage 92.49% 91.08% -1.41%
==========================================
Files 36 22 -14
Lines 7472 6116 -1356
Branches 651 652 +1
==========================================
- Hits 6911 5571 -1340
+ Misses 553 540 -13
+ Partials 8 5 -3 ☔ View full report in Codecov by Sentry. |
src/App.ts
Outdated
} else { | ||
// Events API requests are acknowledged right away, since there's no data expected | ||
// Except function_executed events | ||
await listenerArgs.ack(); | ||
} |
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.
All events that are not function_executed
are automatically acknowledged, preserving the existing behavior 🥇
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.
Overall looks good to me implementation wise!
Two things I'd like to make sure we do before I feel comfortable ✅ this PR:
- Let's study the code coverage report and understand why the code coverage dropped by 1.5%. Which parts of the code is now untested, and what can we do to improve that situation in this PR? What code is relevant for us to cover as part of this work?
- One thing we realized in our explorations during this feature is that the existing auto-acknowledgement of event is a feature that is not tested at all. Let's make sure to add tests for this. Not exactly sure where we should put those tests - maybe
test/unit/App/middleware.spec.ts
? Maybe one test in each of thetest/unit/App/routing-*.spec.ts
files? In the routing files might work: this way, for each of the event classes that bolt-js exposes a different listener registration function for, we can write a test that formalizes the expected acknowledgement behaviour. For the case of custom functions, we'd have two such tests (one for autoack:true and one for autoack:false).
const args = createDummyCustomFunctionMiddlewareArgs({ callbackId: 'my_id' }); | ||
let isAck = false; | ||
await fakeReceiver.sendEvent({ | ||
ack: async () => { |
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.
Tiny nit: can we use sinon here instead of defining a sentinel boolean variable, etc.?
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.
Good point not sure why I did not opt to use this originally
); | ||
} | ||
|
||
describe('App function() routing', () => { |
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.
What about sad path tests? Say a function_executed event comes in with a callback_id that we DO NOT have a listener for - what behaviour is expected?
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.
Great point adding that in 💯
Summary
Most changes in this PR come from approved #2283 but limit the affected behavior to
function_executed
eventsChanges
This PR changes the way to
function_executed
events auto acknowledgement behavior operates. These changes remove auto acknowledgement forfunction_executed
events and lift the logic into a middleware that is then registered to thefunction
event listenerThis allows the
app.function
listener to expose anautoAcknowledge
flag that can be used to disable the auto ack middleware. This is required for the Dynamic Options, since functions used as dynamic inputs mustcomplete
orfail
before acknowledging the request (this provides a crisp user experience).Example
Manual tests
These changes were manually tested against
Testing
npm install
&npm run build
npm install path/to/the/bolt-js/project
to install the built package in a project with a custom step like bolt-js-custom-step-template{ autoAcknowledge: false }
ack
input parameter in your handlerawait ack();
for this specfic handlerFeedback
I've messed around with the
CustomFunction exported types
I am not if these are considered "breaking changes" in this project. There may be a way to work around this.Should there be more unit tests around these changes?
Requirements (place an
x
in each[ ]
)