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

TransitionAborted when performing a full route transition with changed query params #5566

Closed
skoryky opened this issue Sep 9, 2014 · 50 comments
Assignees

Comments

@skoryky
Copy link

skoryky commented Sep 9, 2014

Why does a TransitionAborted error get thrown when performing a full route transition when changing query params?

I am working off of the "Opt-in to full transition via refresh()" example provided at the bottom of the query parameters Ember guide (http://emberjs.com/guides/routing/query-params/).

The only change I made was to log errors:

Ember.RSVP.configure('onerror', function(error) {
  Ember.Logger.assert(false, error);
});

Here is an updated JS Bin: http://jsbin.com/kinajoginedo/1/edit?console,output

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 my app from 1.7.0-beta.1+canary for some time now, but many of my QUnit tests fail when I run them all together. Most of my tests are fine if I run them in isolation. I suspect the TransitionAborted errors may be causing the test failures. However, I'm not sure if TransitionAborted exceptions are normal when performing full transitions. If anyone can confirm one way or the other, that would be very helpful in getting to the root cause of my problems, whatever they might be.

@wagenet
Copy link
Member

wagenet commented Sep 12, 2014

@machty thoughts?

@mewben
Copy link

mewben commented Sep 29, 2014

I'm having this problem too...

@rhinon
Copy link

rhinon commented Oct 16, 2014

Hi guys, any update on this issue? Anything more we can provide?

@Keoven
Copy link

Keoven commented Oct 17, 2014

same here -- I'm getting this error

@elidupuis
Copy link

I am also seeing this error. It's worth noting that RSVP's configure method is deprecated, however the result is the same using RSVP.on.

Ember.RSVP.on('error', function(error) {
  Ember.Logger.assert(false, error);
});

@skoryky
Copy link
Author

skoryky commented Oct 22, 2014

Is this error materially affecting your guys' apps or just your tests?

@elidupuis
Copy link

I'm seeing it in my main app. I was just testing it out—and based on this error I've just taken it out and moved on for now.

@thedoktor
Copy link

I am also seeing this TransitionAborted error being reported for some users via our error tracking service after adding

Ember.RSVP.on('error', function(error) {
  Ember.Logger.assert(false, error);
});

It seems to be triggered by a route whose model is being updated every 2 seconds.

@skoryky
Copy link
Author

skoryky commented Oct 31, 2014

I did some investigating, and it looks like the second call to fireQueryParamsDidChange in getTransitionByIntent (transitionByIntent in my copy of Ember.js 1.7.1) in the router.js library causes the TransitionAborted error (the first call is made in the queryParamsTransition call earlier in the function):

https://github.com/tildeio/router.js/blob/03810a915789549c4798c8eeb7d23e64b9789c75/lib/router/router.js#L64

When I comment out that line, my app seems to work normally and without errors. Seemed like a bug to me, as transitionByIntent is notifying of query param changes twice. However, the second call was implemented by @raytiley for a specific reason:

tildeio/router.js@9a07446

I'm not entirely sure I understand the reason, but is it duplicating the behavior of setting refreshModel to true?

My QUnit tests failing was due to something else entirely (was setting a query param to null in the route deactivate callback, which caused the next test to fail while a transition due to the query param change was attempted).

@machty machty removed the unverified label Oct 31, 2014
@mutewinter
Copy link
Contributor

Experiencing this on Ember 1.8.1.

Edit

I can confirm that commenting the line mentioned by @skoryky fixes the problem.

@shripathee
Copy link

In my case I have to change multiple query params. I am still getting the console errors even after commenting out the line as suggested by @skoryky . However, other than the console errors, the app is behaving as it should.
JSBin: http://jsbin.com/kekowabazi/1/edit
Ember version: 1.8.1

@skoryky
Copy link
Author

skoryky commented Nov 30, 2014

@shripathee, I also encountered your issue. Turns out the fireQueryParamsDidChange callback is called once for each query param you set to refreshModel: true. I'm not really sure when you'd want that kind of behavior (instead of a single notice that any query param changed), so I replaced the queryParams options hash with:

actions: {
  queryParamsDidChange: function() {
    this.refresh();
  }
}

@shripathee
Copy link

@skoryky Yes, this works pretty fine. Thank you.

@kamalaknn
Copy link

I am also facing this issue,

@axsuul
Copy link

axsuul commented Dec 17, 2014

Can also confirm this on 1.8.1 as well in a situation where I have multiple query params having set like

queryParams:
    page:
      refreshModel: true
    query:
      refreshModel: true

@voltidev
Copy link

I'm seeing the same error.

@jspavlick
Copy link

I'm also having this issue. (Ember 1.9.0) Only on refreshModel: true though. refreshModel: false does not cause the error. Doesn't seem to be fatal, though.

@UmaSarma
Copy link

I'm also facing the same issue. Any updates?

@wagenet
Copy link
Member

wagenet commented Dec 24, 2014

I'm putting this on the agenda for our next core team meeting.

@btecu
Copy link
Contributor

btecu commented Mar 6, 2015

I'm running into this issue with Ember 1.11.0-beta.4. Updates?

@gorandev
Copy link

Facing this issue too. It only bugs me because it gets logged as an error -- works fine otherwise (I'm doing pagination and the pages change and everything works fine).

EDIT: using Ember 1.7.0

@tim-evans
Copy link
Contributor

Seeing this on 1.11.0-beta.1+canary.26c1084c.

@r4m
Copy link

r4m commented Mar 18, 2015

I'm facing this issue to and as @gorandev it is only logged but it does not compromise the app flow.
A workaround can be:

      Ember.RSVP.on 'error', (error) ->
        if error && error.message == "TransitionAborted"
          return

@tim-evans
Copy link
Contributor

Hmm...

This is the behavior that I'm trying to implement (which I'm not able to do at the moment):

A user can type (normally) in a search box, which refreshes the model of a route. Currently, if I swallow the TransitionAborted errors, the typing UI doesn't respond well and will replace the text box with the finished transition. I would prefer to discard requests that pile up rather than wait for them to resolve.

export default Ember.Route.extend({
  queryParams: {
    q: { replace: true, refreshModel: true },
    sort: { replace: true, refreshModel: true },
    filter: { replace: true, refreshModel: true }
  },

  model: function(params) {
     return this.store.find('user', params);
  }
}

@richmolj
Copy link

richmolj commented Dec 2, 2015

Looks like @piotrze's Ember.run.once solution worked for me on Ember 1.13, but no longer works on 2.2

@gerry3
Copy link

gerry3 commented Dec 2, 2015

@richmolj the @r4m workaround above still works on 2.2

@izelnakri
Copy link

Please reopen this issue. It still occurs on Ember 2.6 when the queryParams have refreshModel: true

@medokin
Copy link

medokin commented Jul 28, 2016

Ember 2.7

queryParamsDidChange fires multiple time even if nothing has changed, thats why I additionally compare old and new queryParams values.

    queryParamsDidChange: function(a,b) {
      // Compare to prevent refresh if nothing has changed
      if(
        a.page === b.page &&
        a.selectionId === b.selectionId &&
        a.sort === b.sort &&
        a.sortDirection === b.sortDirection
      ){
        return;
      }

      Ember.run.next(this, 'refresh');
    }

@jesseditson
Copy link

jesseditson commented Sep 16, 2016

FYI - still seeing this in 2.8.1, I worked around it by debouncing the refresh calls - here's a Mixin that you can add to routes that use refreshModel: true:

import Ember from 'ember';

/**
 * Debounce Refresh
 * Ember routes with queryParams that have refreshModel double-trigger a refresh:
 * see: https://github.com/emberjs/ember.js/issues/5566
 *
 * Mix this in to routes that define queryParams[param].refreshModel to avoid the TransitionAborted error thrown when double-triggering refreshes.
 */
export default Ember.Mixin.create({
  refreshDebounceThreshold: 100,
  _lastRefresh: null,
  _doRefresh() {
    if (this._lastRefresh) {
      this._lastRefresh();
      this._lastRefresh = null;
    }
  },
  refresh() {
    this._lastRefresh = this._super.bind(this, ...arguments);
    Ember.run.debounce(this, '_doRefresh', this.get('refreshDebounceThreshold'));
  }
});

@supersabillon
Copy link

@jesseditson thanks for the Mixin. There's one issue, when you change the query params of a route, transition to a different page, and then come back to the page with the query params the refresh happens again and causes the error.

@jesseditson
Copy link

@supersabillon ah, when resuming with "sticky" QPs? I've disabled those in the app I'm using, I wonder if that's why I didn't come across that case.

LevelbossMike added a commit to creatubbles/ember-new-relic that referenced this issue Nov 8, 2016
There is a bug in ember's router implementation that triggers
multiple route refreshes when multiple query-params are specified
that are marked with the `refreshModel`-option.

See this github-issue for more detailed information:

emberjs/ember.js#5566

This change makes sure that NewRelic won't pickup those non-user-
facing errors and rethrow an error.
@vlascik
Copy link

vlascik commented Jan 22, 2017

still happening in 2.11.0-beta.2.

@denzo
Copy link

denzo commented Feb 16, 2017

Yes, is still happening to me also in 2.10.0 :(

AddisonSchiller added a commit to AddisonSchiller/isp that referenced this issue Jul 18, 2017
…tain page refeshes from going through and causing promises to be rejected. Certain actions would trigger the function multiple times. Adding the Ember.run.once() function around it stops this from happening.

Setting refreshModel to true under queryParams is what is calling this function.
See the querryParamsDidChange function in https://github.com/emberjs/ember.js/blob/lts-2-8/packages/ember-routing/lib/system/route.js .
See emberjs/ember.js#5566 for more info on the issue, and more possible fixes.
This fix could possibly change some interactions on this route in the future (more queryParams added). If old function is desired, just comment out the new one, and ember will use its default.
For future reference there may be other possible fixes with observers that do not override the default queryParamsDidChange function.
AddisonSchiller added a commit to AddisonSchiller/isp that referenced this issue Jul 18, 2017
…tain page refeshes from going through and causing promises to be rejected. Certain actions would trigger the function multiple times. Adding the Ember.run.once() function around it stops this from happening.

Setting refreshModel to true under queryParams is what is calling this function.
See the querryParamsDidChange function in https://github.com/emberjs/ember.js/blob/lts-2-8/packages/ember-routing/lib/system/route.js .
See emberjs/ember.js#5566 for more info on the issue, and more possible fixes.
This fix could possibly change some interactions on this route in the future (more queryParams added). If old function is desired, just comment out the new one, and ember will use its default.
For future reference there may be other possible fixes with observers that do not override the default queryParamsDidChange function.
felliott pushed a commit to CenterForOpenScience/isp that referenced this issue Aug 8, 2017
 * Override the default queryParamsDidChange[1] method to stop certain
   page refeshes from going through and causing promises to be
   rejected. Certain actions would trigger the function multiple
   times. Adding the Ember.run.once() function around it stops this
   from happening.  Setting refreshModel to true under queryParams is
   what is calling this function.

   See emberjs/ember.js#5566 for more info
   on the issue and more possible fixes.

   This fix could possibly change some interactions on this route in
   the future (e.g. if more queryParams are added). If the old
   function is desired, comment out the new one, and ember will
   use its default.

   For future reference there may be other possible fixes with
   observers that do not override the default queryParamsDidChange
   function.

   [1] https://github.com/emberjs/ember.js/blob/lts-2-8/packages/ember-routing/lib/system/route.js

   [SVCS-393]

   Fixes #172
@aaxelb
Copy link
Contributor

aaxelb commented Oct 11, 2017

Was this silently fixed in 2.12.0? (commit cee49a3)

@wagenet
Copy link
Member

wagenet commented Oct 11, 2017

@aaxelb not intentionally, but possibly it did fix it. Is the behavior correct in 2.12?

@rwjblue
Copy link
Member

rwjblue commented Oct 13, 2017

I reproduced the JSBin (with current Ember versions) and it does indeed seem to be fixed.

https://jsbin.com/cajiji/edit?html,js,output

closing....

@rwjblue rwjblue closed this as completed Oct 13, 2017
@cluis13915
Copy link

This error is throwing too on doing this in a route:

return this.transitionTo(my_route)

Removing return keyword, fix it.

@cadeParade
Copy link

cadeParade commented Nov 2, 2018

This was happening to me in a test only, specifically after upgrading tests to the new(ish) RFC. As @cesarluis13915 said, removing return before a transitionTo fixed my test.

@enspandi
Copy link

enspandi commented Jul 3, 2019

Occured in our project with the Ember 3.11.1 upgrade.
return this.replaceWith(null, id); makes the test fail with TransitionAborted
this.replaceWith(null, id); succeeds 🤷‍♂️

@KalachevDev
Copy link

#18177 is this the same?

@allthesignals
Copy link
Contributor

I'm seeing this appear in error tracking service, Sentry

@wagenet
Copy link
Member

wagenet commented Jul 17, 2019

@rwjblue ping

@mehulkar
Copy link
Contributor

mehulkar commented Sep 20, 2019

Ran into this in 3.11.1. Re-opened in #18416 with a repro. Was able to workaround with @skoryky's solution (thanks!), except that queryParamsDidChange isn't an action now, it's just a method.

rishabhgrg added a commit to TryGhost/Admin that referenced this issue Aug 30, 2021
no issues
refs emberjs/ember.js#5566 (comment)

Member deletion UI gets stuck in UI when deleted via these steps: View member list, filtered by label. Click on a member, delete them. Admin transitions back to previous screen before action is completed — deletion completes successfully but deletion UI hangs.

This happens due to a niche ember bug which causes transitions to abort when transitioning to a route with query params having `refreshModel:true`. The fix is simple one liner with return being separated from the route transition statement.
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