Middleware runs multiple times in some situations #4

Closed
carlos8f opened this Issue Dec 11, 2012 · 4 comments

Projects

None yet

2 participants

@carlos8f
Owner

Still getting a duplication issue where, if routing more than 2 functions at a time, the set of functions runs multiple times on route match.

@meaku
meaku commented Dec 11, 2012

Hi @carlos8f! I just wanted to reopen the old issue.

The example i posted still causes problems:

function getMiddleware(name) {
    return function (req, res, next) {
        console.log(name + " run");
        next();
    };
}

//it adds mws twice if configured this way
router.add(["get", "post"], "/services/*",[mw1, mw2]);

//it works perfectly fine if defined separately
router.get("/services/", [mw1, mw2]);

Maybe you could add a test-case to ensure it's fixed?

Thanks!

@meaku
meaku commented Dec 11, 2012

I just saw you already added the test-case last time. Sorry.

The strange thing is that it worked before.
Might this be related to a node-upgrade? I think this problem appeared after my update to 0.9.15...

@meaku meaku referenced this issue in peerigon/alamid Dec 11, 2012
Closed

Middler-Bug #137

@carlos8f carlos8f pushed a commit that closed this issue Dec 14, 2012
Carlos Rodriguez overhaul item matching, resolves #4 fab29cb
@carlos8f carlos8f closed this in fab29cb Dec 14, 2012
@carlos8f
Owner

Overhauled item.js with a new approach, which should resolve the issue. Performance hasn't degraded at all, awesomely.

****************  middler-routes (5006.49 rps)
****************  express-routes (4699.06 rps)
*******           director-routes (1920.29 rps)
@carlos8f
Owner

Oh, and I published this in v0.5.3 @meaku :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment