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

[BUG] v1.6.x broke redirect in child router config #605

Closed
3cp opened this issue Jun 20, 2018 · 12 comments
Closed

[BUG] v1.6.x broke redirect in child router config #605

3cp opened this issue Jun 20, 2018 · 12 comments
Assignees
Labels

Comments

@3cp
Copy link
Member

3cp commented Jun 20, 2018

I'm submitting a bug report

  • Library Version:
    1.6.1

  • Please tell us about your environment:
    OSX 10.13

  • Node Version:
    8.11.2

  • NPM Version:
    6.1.0

  • JSPM OR Webpack AND Version
    NA

  • Browser:
    all

  • Language:
    ESNext

Current behavior:
With latest v1.6.1, when a route page /child has additional child router config, the redirect in config doesn't work properly.

export class Child {
  configureRouter(config, router) {
    this.router = router;
    config.mapUnknownRoutes('./not-found.html');

    config.map([{
      route: 'test',
      title: 'test',
      name: 'test',
      nav: true,
      moduleId: './test.html'
    }, {
      route: '',
      // this redirects "/child" to "/child/test"
      // but in router 1.6.1, it instead redirects to "/test" (not-found)
      redirect: 'test'
    }]);
  }
}

Expected/desired behavior:
rjs-bundle is not up to date to router 1.6.x, so I built a demo app for the bug https://github.com/huochunpeng/router-bug

  • What is the expected behavior?
    Keep the old behaviour, redirect to the same level of route.

  • What is the motivation / use case for changing the behavior?
    :-( It broke my production app, I need to pin aurelia-router to 1.5.0 to bypass this regression.

@bobum
Copy link

bobum commented Jun 21, 2018

I can confirm this behavior in our app as well

@3cp
Copy link
Member Author

3cp commented Jun 21, 2018

The new implementation of handling child route config "redirect" triggered a timing bug on router baseUrl.

if ('redirect' in config) {
let router = instruction.router;
return router._createNavigationInstruction(config.redirect)
.then(newInstruction => {
let params = Object.keys(newInstruction.params).length ? instruction.params : {};
let redirectLocation = router.generate(newInstruction.config.name, params, instruction.options);
if (instruction.queryString) {
redirectLocation += '?' + instruction.queryString;
}
return Promise.resolve(new Redirect(redirectLocation));
});
}

The new implementation use router.generate(...) to generate url, replaced the old manual resolve. Which is good thing.

The issue is when router.generate(...) got called here, the router._refreshBaseUrl() was NOT called yet. The result is the child router doesn't have a proper baseUrl at this point of time, manifested as missing baseUrl part in redirectLocation.

router._refreshBaseUrl();

I am not clear about the whole picture of how router works, not sure how to make a fix.
cc @EisenbergEffect @davismj

@EisenbergEffect
Copy link
Contributor

@davismj Can you look into this. Appears to be a rather serious couple of issues in the latest router release.

@fragsalat
Copy link

👍 Got this problem as well on main router after updating from 1.5.0 to 1.6.x

@davismj
Copy link
Member

davismj commented Jun 26, 2018

On it.

@balazsmeszegeto
Copy link
Contributor

I was about to submit the very same issue

@josundt
Copy link

josundt commented Jul 4, 2018

Any progress on this?
Upgrading to 1.6.x is no option in my current project till this is OK

@stefan505
Copy link

stefan505 commented Jul 4, 2018

Guys, this issue is very serious. Its completely broken my sub-routers + defaults strategy.

As a long-time Aurelia user / supporter I am very concerned about the recent router problems.

@3cp
Copy link
Member Author

3cp commented Jul 4, 2018

@stefan505 for temporary fix, I use this in my package.json

"aurelia-router": "1.5.0",
"aurelia-templating-router": "1.3.2", // I need to do this for yarn. Didn't test on npm.

The regression is from #515, which can be reverted.

@3cp
Copy link
Member Author

3cp commented Jul 4, 2018

@EisenbergEffect @davismj can we have a hot-fix reverting #515 before further investigation?

It seems many users are waiting for the fix urgently for production apps.

@EisenbergEffect
Copy link
Contributor

Both @davismj and I are on vacation right now. When Matt gets back, this is on the top of his list to address. In the mean time, I recommend rolling back via package.json as described above. We apologize for this. We will get it fixed soon.

@davismj
Copy link
Member

davismj commented Jul 17, 2018

Closed via #610

@davismj davismj closed this as completed Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants