Middleware working

Is the working of middlewares in case of multiple mw’s used together juts like recursion.
i mean that if we move from mw1 to mw2 via next() then should the statements after next() in mw1 should print??

No. It works like break. Once you call next, you break into the next middleware, skipping the rest of the current middleware.

have a look at this code and output
on chrome vhv is printed which is in send of mw3

Yup, Its working as I told. Feel free to elaborate your doubt if this sounds unexpected.

You said that rest of the statements are skipped but here they are interpreted…I mean those statements after next () are also interpreted as if interpretor is coming back to mw2 after interpreting mw3 and then to mw1

Explain this part coz this seems more like recursion and not break

Yeah, you break into the next middleware, skipping the remaining middleware. But once the next middleware completes, the remaining code resumes. It’s more like backtracking. If you don’t want to run the remaining part, return next().

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.