ember-concurrency icon indicating copy to clipboard operation
ember-concurrency copied to clipboard

transitionTo called by route task immediately transitions back

Open bgentry opened this issue 7 years ago • 3 comments

I just ran into a scenario where a route task was calling a function inside my route that itself called .transitionTo() on the route. I was randomly seeing failures with the transition. After doing some debugging on route transitions, it turned out that I was seeing my app transition to the new route and then immediately transition back to the previous one. I didn't have any hooks on the routes in question that might be aborting the transition or anything like that.

Eventually I figured out that if I enqueue that function call w/ the transitionTo inside a runloop, everything works 100% of the time.

Is this expected?

bgentry avatar May 23 '18 05:05 bgentry

@bgentry code you show a snippet of your workaround? I think I'm facing this same issue

tylerturdenpants avatar Jun 23 '18 22:06 tylerturdenpants

I believe this was:

// broken route.js
...
  myTask: task(function*() {
    this.transitionTo("otherRoute");
  }),
// working route.js
...
  myTask: task(function*() {
    Ember.run(() => this.transitionTo("otherRoute"));
  }),

In my own code I had myTask calling another function that contained the transitionTo, but I don't think that's relevant to the issue.

bgentry avatar Jun 25 '18 17:06 bgentry

Same issue when doing:

  myTask: task(function*() {
    this.router.transitionTo("otherRoute");
  }),

esbanarango avatar Jan 26 '22 16:01 esbanarango