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

Transition Rejection -> $transitions.onError triggered all the time #6

Closed
adamlubek opened this issue Jul 4, 2017 · 2 comments
Closed

Comments

@adamlubek
Copy link

hey,
When running sample app I get Transition Rejection a lot and as a result $transitions.onError triggered all the time. Steps to reproduce:

  1. npm install
  2. open requiresAuth.hook.ts -> add "$transitions.onError({}, (transition) => {console.log('error');})" (see screenshot on bottom)
  3. npm start
  4. click any button (messages/contacts/preferences)
  5. browser console:

Similar thing happens when refreshing page in the browser e.g.

  1. npm start
  2. click contacts
  3. login as first available user
  4. hit F5 or browser refresh button
  5. again, Transition Rejection and $transitions.onError is triggered.

angularhybridsampleapperror

Generally, just clicking through the pages or refreshing the page surely shouldn't cause rejections and triggering error handling?

@adamlubek
Copy link
Author

any update on this please? We would like to use UI-router for production code but issues like that are stopping us.

@christopherthielen
Copy link
Member

hi @adamlubek sorry for the late (probably too late) response.

Every transition, once started, is either successful (meaning the destination state is active, etc) or it fails/errors. When a transition is redirected, the original transition is cancelled and a new one is started to the redirect target. Thus, the original transition has technically errorred. See this section of the Transition guide for more information.

If you want to filter specific types of errors, you can do so in your onError hook by checking the type of the TransitionRejection (see RejectType docs). For RejectType.SUPERSEDED, there is an additional redirected flag which tells you if the transition was superseded because of a redirect.

.onError({}, transition => {
  const err = transition.error();
  switch (err.type) {
    case RejectType.ERROR:
      // do error stuff
      break;
    case RejectType.SUPERSEDED:
    case RejectType.IGNORED:
      // ignore
      break;
  }
});

Sorry again, and hope this is helpful information

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

No branches or pull requests

2 participants