Pipeline middleware runs twice


Hello everyone,

I’m working on my first Expressive application and I just noticed that any pipeline middleware registered before the DispatchMiddleware::class runs twice. If I pipe a middleware after DispatchMiddleware::class, it still runs once, although the route is found and the registered handler for it returns a response.

I discovered this while testing a middleware that needs to write a file to a folder and it just writes two files for each request. The application is created based on the Skeleton app and it’s using the latest versions for both Expressive and the Skeleton app. I’ve tested both with the ApplicationConfigInjectionDelegator and without it.

If I add my file-writing middleware as a routed middleware, it works just as expected (runs only once, if added before the handler and doesn’t run, if added after it) …

Did anyone experienced something similar?

Thank you
All the best


I think it was a problem with my local server, as after some more testing, it works as expected without any changes. Pretty strange, but I have no other explanation. I think the post can be deleted.
Thank you.