Code Monkey home page Code Monkey logo

Comments (3)

weierophinney avatar weierophinney commented on June 14, 2024

Okay, I've been able to create a small project that has the dependencies necessary to run the test, and verified the behavior.

For those who have clicked through to the gist, it's the second test that fails. Essentially, the first middleware executes, and then it descends into the nested pipeline, which executes correctly - but once complete, it does not return to the parent middleware.

This is quite odd, as this is almost exactly the sort of behavior that occurs when you run routed pipelines, which definitely work!

I need to investigate more here to determine if the issue is with how the MiddlewareFactory is creating the nested pipeline, or if there's an issue within MiddlewarePipe that needs to be resolved. I'll post more when I've had more time to investigate.

from zend-expressive.

weierophinney avatar weierophinney commented on June 14, 2024

I figured out the problem: https://github.com/zendframework/zend-expressive/blob/master/src/MiddlewareContainer.php#L66-L68

What happens here is that MiddlewarePipe is also a RequestHandlerInterface, which means that pipelines then get cast to RequestHandlerMiddleware, which then calls handle() on the pipeline, instead of process().

Locally, I changed that to:

if ($middleware instanceof RequestHandlerInterface
    && ! $middleware instanceof MiddlewareInterface
) {
    $middleware = new RequestHandlerMiddleware($middleware);
}

This allows both of your tests to pass, which is good. Next step is to figure out a succinct way to reproduce the issue as a unit test, at which point I can write a patch.

from zend-expressive.

gsteel avatar gsteel commented on June 14, 2024

That's great! Thanks ever so much - That test I wrote is a country mile from succinct I'll agree 😂

from zend-expressive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.