Skip to content

Unhandled promise rejections after redirect #3404

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

Closed
1 of 3 tasks
aj-dev opened this issue Apr 14, 2017 · 2 comments
Closed
1 of 3 tasks

Unhandled promise rejections after redirect #3404

aj-dev opened this issue Apr 14, 2017 · 2 comments

Comments

@aj-dev
Copy link
Contributor

aj-dev commented Apr 14, 2017

This issue tracker is for Bug Reports and Feature Requests only.
Please direct requests for help to StackOverflow. See http://bit.ly/UIR-SOF for details.

This is a:

  • Bug Report
  • Feature Request
  • General Query

My version of UI-Router is: v1.0.0-rc.1

Bug Report

Current Behavior:

Unhandled promise rejection errors in console

Expected Behavior:

No unhandled promise rejection errors in console

Link to Plunker that reproduces the issue:

Too complex to create a plunkr test case.

Since update to v1.0.0-rc.1, I noticed that a lot of unhandled promise rejection errors were logged to the console in some complex transition sequences, involving multiple onBefore, onStart and redirect hooks.

I made sure that all promises in the application code had their catch handlers attached to avoid unhandled rejection errors but that didn't fix the issue.

I then decorated $qProvider as described here #2889 (comment) and narrowed it down to this line:

trans.promise.then(update);

If I add a catch() there, no unhandled promise rejection errors are logged to the console.

Logging the current transition promise stack with the following code:

trans.promise.then(update).catch(function (error) {
                            console.log("Unhandled promise rejection", error, trans.promise.$$state.stack);
                        });

I can see that error contains a Rejection with a target state that I'm redirecting to:

Rejection {type: 2, message: "The transition has been superseded by a different transition", detail: TargetState, redirected: true}

and trans.promise.$$state.stack contains:

Error
    at Promise.set [as $$state] (.../decorator-service.js:23:36)
    at new Promise (.../libs/angular.js:16789:18)
    at new Deferred (.../libs/angular.js:16780:34)
    at Function.defer (.../libs/angular.js:16776:12)
    at new Transition (.../libs/angular-ui-router.js:6081:38)
    at TransitionService.create (.../libs/angular-ui-router.js:4337:16)
    at StateService.transitionTo (.../libs/angular-ui-router.js:5613:56)
    at StateService.go (.../libs/angular-ui-router.js:5514:21)
    at .../libs/angular-ui-router.js:7929:24
    at .../libs/angular.js:20178:31

The same error is logged 4 times consecutively.

@christopherthielen
Copy link
Contributor

Thank you so much for tracking this down! I wish I had noticed this analysis earlier. I'll get a .catch() handler in there ASAP.

@christopherthielen
Copy link
Contributor

1.0.4 is released

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