Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

middleware TypeError for not found routes #168

Closed
1 of 3 tasks
asyncLiz opened this issue Jul 19, 2019 · 1 comment · Fixed by #169
Closed
1 of 3 tasks

middleware TypeError for not found routes #168

asyncLiz opened this issue Jul 19, 2019 · 1 comment · Fixed by #169
Labels

Comments

@asyncLiz
Copy link

asyncLiz commented Jul 19, 2019

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

When using an action and calling context.next() with child routes, a TypeError is thrown if the route does not exist. I expected a route not found error to be thrown.

https://jsbin.com/zicukiyoxu/1/edit?html,output

    const router = new UniversalRouter({
      path: '/',
      async action({ next }) {
        console.log('middleware: start');
        const child = await next();
        console.log('middleware: end');
        return child;
      },
      children: [
        {
          path: '/hello',
          action() {
            console.log('route: return a result');
            return 'Hello, world!';
          }
        }
      ]
    });

    
    router.resolve('/hello/404');
universal-router.js:439 Uncaught (in promise) TypeError: Cannot read property 'route' of undefined
    at next (VM173 universal-router.js:439)
    at VM173 universal-router.js:462

If you comment out the action middleware, you get the expected error message

Uncaught (in promise) Error: Route not found
    at next (VM173 universal-router.js:451)
    at VM173 universal-router.js:462

I still get the TypeError if I add a fallback route using '*'. Without the action middleware and with a fallback, the fallback route is correctly returned and no error is thrown.

@frenzzy
Copy link
Member

frenzzy commented Jul 19, 2019

Thank you for the bug report! The fix is released: v8.2.1 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants