Description
Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.
Version
4.16.2
Describe the bug
The turncontext middlware chain is as follows:
botbuilder-python/libraries/botbuilder-core/botbuilder/core/turn_context.py
Lines 287 to 304 in a7f5d91
Notice how the "logic" runs after all the middlware has run? This prevents any middlware from awaiting the result of the "next" middleware. This means that if you wanted to wait for the "response" from the last middleware (which runs the actual logic to send the activity), you can't.
This is in contrast with how the middleware for js is built:
https://github.com/microsoft/botbuilder-js/blob/3b8fcab21a0a5434706da8eace17117722ffd78b/libraries/botbuilder-core/src/turnContext.ts#L864.
Here, if you wanted to do:
async function MyMiddleware(context, args, next) {
console.log(args)
const res = await next()
console.log(res)
}
you can. But in python, the same thing would not be possible because the handlers don't wait for the last handler (which is the actual logic) to be run in the same chain as all the handlers.