-
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
Fix #355 - processMiddleware doesn't wait for last global middleware's call to next()
#394
Conversation
Codecov Report
@@ Coverage Diff @@
## master #394 +/- ##
=======================================
Coverage 81.33% 81.33%
=======================================
Files 7 7
Lines 525 525
Branches 150 150
=======================================
Hits 427 427
Misses 70 70
Partials 28 28 Continue to review full report at Codecov.
|
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.
Thanks for fixing this! LGTM. We should merge this for Bolt 1.x series. Bolt v2 no longer has this issue (the new implementation by @barlock addressed the issue)
I'd like to eliminate this 2% drop. I'll make a pull request to your branch. |
hmm, it's a bit weird but now it seems to be fine. Looks ready to merge anyways. @aoberoi @stevengill I'd like to merge this PR tomorrow in my local time. Take a look at this when you have a chance until then. |
@seratch That is weird. I couldn't figure out how coverage had dropped after I merged latest master. Thanks for looking! |
Let me merge this now. |
@seratch @stevengill I was just thinking that if folks using bolt upgrade to a release with this fix and had custom global middleware that incorrectly relied on this behavior (specifically, that didn't call |
@artgillespie I think communication can be like this.
Probably, the English sentence can be polished by others, but I think we should have the above message in the release note and the document in English/Japanese. Any thoughts? @stevengill @aoberoi @shaydewael |
Summary
This provides a test case for #355 (see src/middleware/process.spec.ts) as well as a proposed fix.
What I think is happening is that for the last global middleware,
processMiddleware
is passing a noop next function and calling next on the next process tick. This leads to unexpected results when the last (or only) global middleware is async, as is the case if you implement a conversation store as outlined hereI had to update a couple global middleware implementations in App.spec.ts that were relying on this behavior and not calling
next()
.Requirements (place an
x
in each[ ]
)