Skip to content

Commit 4ddde3c

Browse files
committed
Return from middleware runner
Not returning caused a bug, where runner would attempt continuing running middleware after original action was already called.
1 parent 23de992 commit 4ddde3c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/middleware.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export function runWithMiddleware<
2727
actions: RetType<InitActions<TState, TContexts>>,
2828
actionKey: string,
2929
args: TArgs
30-
) {
30+
): TReturn | Promise<TReturn> {
3131
const [first, ...rest] = middleware
3232

3333
const action = actions[actionKey]
3434

3535
if (first === undefined)
36-
actionCaller(action, actions)(args)
36+
return actionCaller(action, actions)(args)
3737

38-
first((nextArgs) => runWithMiddleware(rest, actions, actionKey, nextArgs), actionKey, args)
38+
return first((nextArgs) => runWithMiddleware(rest, actions, actionKey, nextArgs), actionKey, args)
3939
}
4040

4141
const actionCaller = <

0 commit comments

Comments
 (0)