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

[ng2] Uncaught (in promise): TransitionRejection(type: 5, message: The transition was ignored., detail: "undefined") #2676

Closed
ocombe opened this issue Apr 6, 2016 · 21 comments

Comments

@ocombe
Copy link
Contributor

ocombe commented Apr 6, 2016

A bug easy to reproduce with the ng2 ui router, just start the quickstart example (https://github.com/ui-router/quickstart-ng2), click on one of the state links (Foo for example), then reclick on Foo.

You get the following error in the console:

EXCEPTION: Error: Uncaught (in promise): TransitionRejection(type: 5, message: The transition was ignored., detail: "undefined")
browser_adapter.js:76 EXCEPTION: Error: Uncaught (in promise): TransitionRejection(type: 5, message: The transition was ignored., detail: "undefined")BrowserDomAdapter.logError @ browser_adapter.js:76BrowserDomAdapter.logGroup @ browser_adapter.js:86ExceptionHandler.call @ exception_handler.js:56(anonymous function) @ application_ref.js:193schedulerFn @ async.js:122SafeSubscriber.__tryOrUnsub @ Subscriber.js:166SafeSubscriber.next @ Subscriber.js:115Subscriber._next @ Subscriber.js:74Subscriber.next @ Subscriber.js:51Subject._finalNext @ Subject.js:124Subject._next @ Subject.js:116Subject.next @ Subject.js:73EventEmitter.emit @ async.js:111NgZone._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js:119NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:65ZoneDelegate.handleError @ zone.js:310Zone.runGuarded @ zone.js:218drainMicroTaskQueue @ zone.js:469ZoneTask.invoke @ zone.js:408
browser_adapter.js:76 STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js:76ExceptionHandler.call @ exception_handler.js:58(anonymous function) @ application_ref.js:193schedulerFn @ async.js:122SafeSubscriber.__tryOrUnsub @ Subscriber.js:166SafeSubscriber.next @ Subscriber.js:115Subscriber._next @ Subscriber.js:74Subscriber.next @ Subscriber.js:51Subject._finalNext @ Subject.js:124Subject._next @ Subject.js:116Subject.next @ Subject.js:73EventEmitter.emit @ async.js:111NgZone._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js:119NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:65ZoneDelegate.handleError @ zone.js:310Zone.runGuarded @ zone.js:218drainMicroTaskQueue @ zone.js:469ZoneTask.invoke @ zone.js:408
browser_adapter.js:76 Error: Uncaught (in promise): TransitionRejection(type: 5, message: The transition was ignored., detail: "undefined")
    at resolvePromise (zone.js:517)
    at zone.js:494
    at justjs.js:17
    at new ZoneAwarePromise (zone.js:563)
    at Function.coreservices_1.services.$q.reject (justjs.js:17)
    at RejectFactory.ignored (rejectFactory.js:51)
    at Transition.run (transition.js:285)
    at TransitionManager.runTransition (transitionManager.js:50)
    at StateService.transitionTo (stateService.js:281)
    at StateService.go (stateService.js:210)
    at UiSref.go (uiSref.js:113)
    at AbstractChangeDetector.ChangeDetector_App_0.handleEventInternal (viewFactory_App:242)
    at AbstractChangeDetector.handleEvent (abstract_change_detector.js:57)
    at AppView.triggerEventHandlers (view.js:221)
    at eval (viewFactory_App:349)
    at dom_renderer.js:282
    at dom_events.js:28
    at ZoneDelegate.invoke (zone.js:306)
    at Object.NgZoneImpl.inner.inner.fork.onInvoke (ng_zone_impl.js:44)
    at ZoneDelegate.invoke (zone.js:305)
    at Zone.runGuarded (zone.js:215)
    at NgZoneImpl.runInner (ng_zone_impl.js:75)
    at NgZone.run (ng_zone.js:220)
    at HTMLAnchorElement.outsideHandler (dom_events.js:28)
    at ZoneDelegate.invokeTask (zone.js:339)
    at Zone.runTask (zone.js:237)
    at HTMLAnchorElement.ZoneTask.invoke (zone.js:405)BrowserDomAdapter.logError @ browser_adapter.js:76ExceptionHandler.call @ exception_handler.js:59(anonymous function) @ application_ref.js:193schedulerFn @ async.js:122SafeSubscriber.__tryOrUnsub @ Subscriber.js:166SafeSubscriber.next @ Subscriber.js:115Subscriber._next @ Subscriber.js:74Subscriber.next @ Subscriber.js:51Subject._finalNext @ Subject.js:124Subject._next @ Subject.js:116Subject.next @ Subject.js:73EventEmitter.emit @ async.js:111NgZone._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js:119NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:65ZoneDelegate.handleError @ zone.js:310Zone.runGuarded @ zone.js:218drainMicroTaskQueue @ zone.js:469ZoneTask.invoke @ zone.js:408
zone.js:443 Unhandled Promise rejection: TransitionRejection {type: 5, message: "The transition was ignored.", detail: undefined} ; Zone: angular ; Task: HTMLAnchorElement.addEventListener:click ; Value: TransitionRejection {type: 5, message: "The transition was ignored.", detail: undefined}consoleError @ zone.js:443drainMicroTaskQueue @ zone.js:472ZoneTask.invoke @ zone.js:408
zone.js:445 Error: Uncaught (in promise): TransitionRejection(type: 5, message: The transition was ignored., detail: "undefined")(…)
@pdanpdan
Copy link
Contributor

Can you please fix the same problem for ng1?

@christopherthielen christopherthielen modified the milestones: 1.0.0-beta, 1.0.0-alpha.5 Jun 21, 2016
@christopherthielen
Copy link
Contributor

christopherthielen commented Jun 21, 2016

@adharris reports that this is still an issue in alpha.5 when a TargetState is returned from an onEnter hook.

I return a StateService.target from an onEnter hook, and get EXCEPTION: Error: Uncaught (in promise): TransitionRejection(type: 2, message: The transition has been superseded by a different transition

@christopherthielen
Copy link
Contributor

Can you please fix the same problem for ng1?

@pdanpdan is there an issue for this for ng1? I'm not aware of the problem existing? Can you show me?

@christopherthielen christopherthielen modified the milestones: 1.0.0-alpha.5, 1.0.0-beta Jun 26, 2016
@christopherthielen
Copy link
Contributor

Can't reproduce the report by @adharris that TargetState returned from onEnter causes an Uncaught in promise. Resetting milestone to alpha.5 and closing so this doesn't block the beta release.

@christopherthielen christopherthielen modified the milestones: 1.0.0-beta, 1.0.0-alpha.5 Jun 27, 2016
@christopherthielen
Copy link
Contributor

Able to reproduce now using @adharris example: https://github.com/adharris/quickstart-ng2/tree/4e5a06cf8ce5c596ae0d15af7359ab4b8ad67d36

Will fix in beta.1

@orneryd
Copy link

orneryd commented Dec 14, 2016

this also happens in the redirectTo hook on the state declaration.

@christopherthielen
Copy link
Contributor

This should be fixed. Are you using the latest version? Can you explain exactly how to reproduce it?

@orneryd
Copy link

orneryd commented Dec 15, 2016

so, responding with anything inside the redirectTo on a state definition results in the transition superseded error message. it may be related to a different issue
#2977

      views: {
        '': {
          templateUrl: 'views/main/main.html',
          controller: 'MainCtrl',
          controllerAs: 'main'
        }
      },
      redirectTo: function(trans){
// this causes an error message in the console 
        return trans.getResolveValue('startRoute');
//so does 
       return trans.router.stateService.target(trans.getResolveValue('startRoute'), newParams, stateOptions);
      }

@christopherthielen
Copy link
Contributor

Are you sure you're on the latest version (1.0.0-beta.3)? You shouldn't get a superseded error when a redirect happens. Is the redirect functioning properly, but you get the superseded message?

@orneryd
Copy link

orneryd commented Dec 15, 2016 via email

@christopherthielen
Copy link
Contributor

@timothyswt if you verify you're on the latest, can you open a new issue for this? I can't reproduce it.

@orneryd
Copy link

orneryd commented Dec 21, 2016

@christopherthielen yes, I can reproduce it on Beta 3

@garygentry
Copy link

After updating to ui-router 1.0.0-rc.1 (from beta3) and to angular 1.6 (from 1.5.8), I'm now getting the "Possibly unhandled rejection" error, with "The transition has been superceded by a different transition". Looking at the $trace output, it appears this is a result of redirectTo on my state (the initial transition is rejected and shows the "superceded" message in the trace, then successfully transitions to the state in redirectTo).

From the comments, I gather this would have been fixed? Am I doing something wrong?

@christopherthielen
Copy link
Contributor

I think beta.3 and above shouldn't have this problem.

Do you happen to use the ui router visualizer too?

@garygentry
Copy link

No

@garygentry
Copy link

I just installed it. The chevrons show [success] -> [redirected] -> [success], while the (massive!) error gets dumped to the console...

@christopherthielen
Copy link
Contributor

I was asking because I think the visualizer itself can cause this error to be logged. Thanks for following up.

@smhc
Copy link

smhc commented Feb 2, 2017

I am also seeing:

angular.js:14328 Possibly unhandled rejection: {"type":2,"message":"The transition has been superseded by a different transition","detail":{"deferred":{"promise":{"$$state":

With code similar to the below:

var onBeforeStateHook = function(transition) {
    if (!user.isLoggedIn()) {
        if (transition.to().name !== 'login') {
            var $state = transition.router.stateService;
            return $state.target('login');
        } else {
            return true;
        }
    } else {
        return true;
    }
}

$transitions.onBefore({}, onBeforeStateHook);

Stack trace for creation of unhandled rejected promise:

app.js:111111:33)\n    
at new Promise (angular.js:16605:18)\n   
at new Deferred (angular.js:16596:34)\n    
at Function.defer (angular.js:16592:12)\n    
at new Transition (angular-ui-router.js:6081:38)\n    
at TransitionService.create (angular-ui-router.js:4337:16)\n    
at Transition.redirect (angular-ui-router.js:6459:59)\n    
at angular-ui-router.js:5602:47\n    
at processQueue (angular.js:16648:37)\n    
at angular.js:16692:27","value":{"views":....

angular 1.6.1 and ui-router 1.0.0-rc1

The following modification suppresses the errors but breaks redirection:

// issue #2676
var silenceUncaughtInPromise = function (promise) {
    //return promise.catch(function (e) { return 0; }) && promise;
    return promise.catch(function (e) { return 0; });
};

So it appears to be an issue with this function.

@christopherthielen
Copy link
Contributor

I believe this is fixed by ui-router/core@a7464bb

@mocsharp
Copy link

mocsharp commented May 3, 2017

@christopherthielen Is it possible to use 1.0.0-rc1 with ui-router/core that has the fix or do we have to wait for a new release?

For some reason, I am suddenly getting the following error after I added a new route. The new route I added has a different state name and different URL but it is being "ignored" due to "All states and parameters in the To and From paths are identical" Any idea?

TransitionRejection(type: 2, message: The transition has been superseded by a different transition, detail: Transition#8( 'home'{} -> 'home'{} ))
$defaultErrorHandler @ stateService.js:39
(anonymous) @ stateService.js:371
processQueue @ angular.js:16696
(anonymous) @ angular.js:16712
$eval @ angular.js:17994
$digest @ angular.js:17808
$apply @ angular.js:18102
(anonymous) @ angular.js:19950
completeOutstandingRequest @ angular.js:6045
(anonymous) @ angular.js:6324

@christopherthielen
Copy link
Contributor

@mocsharp 1.0.0 final was just released. I'm closing this ticket because it's a confusion of angular 1 angular 2. If there is still a problem, let's open a different ticket.

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

No branches or pull requests

7 participants