question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

visit() throws TransitionAborted error

See original GitHub issue

As discussed in Slack, I was unexpectedly seeing failing tests where a transition was aborted. ApplicationInstance#visit is throwing it here

As I said I cannot share the app, but this is the human readable test spec (we have a rather exotic test setup with ember-cli-yadda 😉):

  Scenario: Access restricted page as invited user and login
    Given there exists a user with username "testname" and password "testpw"
    And I am an invited user
    And I am on the homepage
    When I go to the user profile page
    Then I should still be on the homepage
    And I should see the login modal
    When I insert "testname" as the username
    And I insert "testpw" as the password
    And I submit the login form
    Then I should be on the user profile page

The I go to the user profile page step is throwing the exception, which is calling visit('/user/profile') internally.

I quickly assembled this little repro, that resembles what we were doing in a very minimal way: https://github.com/simonihmig/ember-visit-transition-abort

All the acceptance tests are passing, with the exception of this last one: https://github.com/simonihmig/ember-visit-transition-abort/blob/master/tests/acceptance/auth-test.js#L36-L40

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:16
  • Comments:39 (15 by maintainers)

github_iconTop GitHub Comments

13reactions
rwjbluecommented, Sep 9, 2020

Just to check in here, I’ve been trying to track down exactly what is going on and I think I have a fairly good picture. Essentially what is happening is that the secondary transition completes during the beforeModel/model/afterModel of the first one, and since the full secondary transition has completed the router’s error handling throws this error instead of entangling the new transition with it like we do when there is an active transition.

Ultimately, returning anything other than the actual resulting Transition object will cause the error reported here to bubble up. This includes making any of the beforeModel/model/afterModel methods themselves async (because then you are returning a Promise not a Transition), or returning an RSVP.Promise that later resolves to a Transition (e.g. return this.store.findRecord('post', 1).then((record) => if (record.whatever) { return this.transitionTo(...); }).

I know this is what folks were reporting all along, but now I actually understand it 😩. Sorry for taking so long to dig in here. I’m trying to work up a solution using @sethphillips’s reproduction.

8reactions
ppcanocommented, Aug 21, 2018

I am also experiencing this issue when migrating our test suite (Ember 2.17 & ember-cli-qunit ^4.1.1)

We are using transition.abort and transition.retry to handle route authentication at the route level as suggested on the Preventing and Retrying Transitions guide.

Based on @NullVoxPopuli guidance, our current workaround has been to implement a wrapper of the visit helper:

import { visit } from '@ember/test-helpers';

export default async function visitWithAbortedTransition(url) {

  try {
    await visit(url);
  } catch(error) {
    const { message } = error;
    if (message !== 'TransitionAborted') {
      throw error;
    }
  }

};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ember TransitionAborted when performing a full route ...
If you click the "Change it" button, you'll see a TransitionAborted error thrown in the console. I've been trying to upgrade Ember in...
Read more >
TransitionAborted when performing a full route transition ...
If you click the “Change it” button, you'll see a TransitionAborted error thrown in the console. I've been trying to upgrade Ember in...
Read more >
TransitionAborted should be a subclass of Error, not a POJO
Ember throws TransitionAborted objects as errors, but their API is inconsistent with Error (e. g. no stack property and .toString() is ridiculously ...
Read more >
Ng1_state_events - UI-Router
An event broadcast on $rootScope when an error occurs during transition. ... from transitionTo() will be rejected with a 'transition aborted' error.
Read more >
Heroku Connect Log Messages and Common Errors
This article documents some of the errors and messages you see in those logs. For information about Heroku External Objects logging, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found