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

fix(transitions): prevent unexpected errors on ember transition #2988

Merged
merged 1 commit into from
Oct 22, 2020
Merged

fix(transitions): prevent unexpected errors on ember transition #2988

merged 1 commit into from
Oct 22, 2020

Conversation

arnaudbesnier
Copy link
Contributor

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests => the fix looks obvious to me.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

@@ -22,7 +22,7 @@ export function initialize(appInstance: ApplicationInstance): void {

function getTransitionInformation(transition: any, router: any) {
const fromRoute = transition?.from?.name;
const toRoute = transition ? transition.to.name : router.currentRouteName;
const toRoute = transition && transition.to ? transition.to.name : router.currentRouteName;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how it can happen but, in my EmberJS project using ember-simple-auth after a login the transition object from the login page to the default authenticated page contains no to key.
route.currentRouteName is well defined.

This defensive programming contribution fixes my issue.

@kamilogorek kamilogorek merged commit 5becce1 into getsentry:master Oct 22, 2020
@kamilogorek
Copy link
Contributor

Thanks! Better safe than sorry.

@miguelcobain
Copy link

miguelcobain commented Oct 23, 2020

In case you're interested, here is the reason it fails:

When aborting a transition on an initial load where the transition's from is null the router sets the to the from of the transition you where coming from. Putting a guard against this null to value now.

Taken from a similar fix from ember-css-components: webark/ember-component-css#324

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

Successfully merging this pull request may close these issues.

3 participants