diff --git a/src/helper/compose.ts b/src/helper/compose.ts index 2ea268c..07f8156 100644 --- a/src/helper/compose.ts +++ b/src/helper/compose.ts @@ -36,15 +36,15 @@ function dispatch( if (idx < middlewareList.length) { const middleware = middlewareList[idx]; - maybePromise = middleware({ + const t = middleware({ ...ctx, - proceed: () => { - return dispatch(middlewareList, idx + 1, stack, ctx); - }, + proceed: () => dispatch(middlewareList, idx + 1, stack, ctx), } as Context); if (middleware.awaitPromise) { - maybePromise = Promise.resolve(maybePromise); + maybePromise = Promise.resolve(t); + } else { + maybePromise = t; } } else if (ctx.proceed) { maybePromise = ctx.proceed();