10

After I have changed from ngRoute to angular-ui-router the console shows always 4 errors stating: Possibly unhandled rejection: {}

I did not noticed any "problem" in the behavior of the application I am building, but I would like to get rid of it.

Any idea what does it mean and how to solve it?

Here an screenshot: enter image description here

2

4 Answers 4

22

This issue is found in 1.5.9 and 1.6.0-rc-0. More details at https://github.com/angular-ui/ui-router/issues/2889

Patch solution is to manually disable unhandled rejections.

app.config(['$qProvider', function ($qProvider) {
    $qProvider.errorOnUnhandledRejections(false);
}]);
Sign up to request clarification or add additional context in comments.

4 Comments

But isn't debugging phantom exception errors just that much more fun??
Thanks for the answer. Was struggling after upgrading from 1.4.4 to 1.7.7
So, you suggest to suppress all errors? Including the real ones? Have fun debugging those. This is dangerous advice and ought not to have been upvoted, let alone so often.
This advice was given 3.5 years ago, when this issue suddenly caused many production upgrade errors. The proper overall approach is to work through addressing the causes of the error message, while using the bandaid suppression in production in the process.
1

I used the next solution

    $http.get('/api/get').then(function(result) {
       // ... stuff here
    }).catch(angular.noop);

it's equals to

$http.get('/api/get').then(function(result) {
  // ... stuff here
}).catch(function(){});

Comments

1

If you look at the logic for uiCanExit in angular-ui-router file(I'm using v1.0.16), it checks only for resolved promise but not for a rejected promise. It is something like:

promise.then(function (val) { 
    return val !== false ? next_transition : current_transition
});

Just return a resolved promise with false value to cancel transition. e.g.,

defer.resolve(false)

Comments

0

Resolve the promise with false if you are trying to abort a transition.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.