-
Notifications
You must be signed in to change notification settings - Fork 404
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
Refactor middleware processing (v2) #440
Refactor middleware processing (v2) #440
Conversation
the main difference is this implementation aggregates errors from multiple failed listener middleware chains into a single error which captures all of them. the previous implementation is mostly commented out. lint is passing, tests are failing.
file where the old one was.
through scope closure. might as well remove to keep things tidy.
There's a few things that I think could be improved in the future coming out of this PR. The biggest one is the fact that the The problem with this is for TypeScript users who are writing middleware (global or listener), they will have to conditionally check the existence of the It would be ideal if in the future we could separate the |
@@ -55,7 +55,7 @@ import { | |||
AppInitializationError, | |||
MultipleListenerError, | |||
} from './errors'; | |||
import promiseAllsettled, { PromiseRejection } from 'promise.allsettled'; | |||
import allSettled = require('promise.allsettled'); // tslint:disable-line:no-require-imports import-name |
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.
i went down a massive rabbit hole trying to get this to work with regular ES Module import ... from ...
syntax. I didn't leave a trail of where this led me in the code, but if anyone comes back looking for an explanation here it is:
there's an issue with a difference between the types and the runtime. its described in detail here: es-shims/Promise.allSettled#5. the conclusion is that the rumtime behavior is spec-compliant, but typescript's output for compiling (downleveling) the import and calls are wrong. an issue was created for that: microsoft/TypeScript#35420.
the workaround suggested also did not work. a different error occurred (lost the exact error message but its not too hard to recreate if you need it). in the end i decided that the quickest fix here would be to just use the uglier, non-standard, less consistent import
syntax.
hopefully when we update to a minimum node version of >= 12.9.0 or when we upgrade our minimum TypeScript version (which we don't declare right now) to one where the bug is fixed, this problem will just go away.
9947553
to
13cbd88
Compare
Codecov Report
@@ Coverage Diff @@
## @slack/bolt@next #440 +/- ##
====================================================
+ Coverage 85.71% 86.05% +0.34%
====================================================
Files 7 7
Lines 532 538 +6
Branches 156 157 +1
====================================================
+ Hits 456 463 +7
Misses 48 48
+ Partials 28 27 -1
Continue to review full report at Codecov.
|
I can make a couple changes to improve coverage. |
yussss, finally increased coverage. |
I've played around with the For your reference: here is my branch that works. |
Summary
This PR mainly resolves two issues:
context
. The variables and types that used context to refer to the set of listener arguments have been removed/renamed.Requirements (place an
x
in each[ ]
)