TIL — Middy
I ran into something last week that I wanted to share with you all!
TIL: Middy
I ran into something last week that I wanted to share with you all!
TLDR: If you’re using middy, make sure that any after middleware that returns a value is always on top.
For after middleware, middy does it in *reverse order (super intuitive, right?), so it executes what you attached first as the last* thing it calls.
Additionally, returning in after middleware means that you are stopping the whole execution flow.
All of this tripped me up the other day. Turns out that one middleware function returns, instead of just modifying data. By carelessly placing it "too late" in the chain, I stopped the extire execution flow. A bunch of middleware was skipped. I almost shipped something that worked in some routes, and not other routes.
The remedy? If it returns, move it higher up. Even better — don’t return unless you mean to.

By moving up the function that returned, it allowed all the after middleware below it to still be called.
Hope this PSA saves someone a headache!
메타데이터
- post_id
- ecc4abcfe58b
- slug
- til-middy-ecc4abcfe58b
- url
- https://medium.com/@mackenzie.gonzales.k_98971/til-middy-ecc4abcfe58b
- canonical_url
- https://medium.com/@mackenzie.gonzales.k_98971/til-middy-ecc4abcfe58b
- author_url
- https://medium.com/@mackenzie.gonzales.k_98971
- status
- ok
- fetched_at
- 2026-07-22 00:40:48