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 on a visit() #373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spencer516
Copy link
Contributor

We ran into this issue where an aborted transition (which was the behavior we expected) was causing the visit() helper to reject failing our test prematurely.

I don't think this was the case before when writing Acceptance Tests before (it may just be the nature of awaiting promises now); but this also feels unexpected or broken.

I'm not sure of the implications of this fix to suppress the error if it's message is TransitionAborted.

Are there times when we would want that promise to reject when a transition aborts? Should this be configurable instead?

Something like:

visit('/home', { ignoreAbortedTransitions: true });

Copy link
Contributor

@simonihmig simonihmig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to run prettier on your changes, to make Travis happy! :)

await visit('/purgatory');
await visit('/');

assert.equal(currentURL(), '/purgatory');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might miss something obvious, but why is the current URL expected to be /purgatory here, after having visited /?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because the transition out of /purgatory is aborted in the willTransition action

@rwjblue
Copy link
Member

rwjblue commented Jan 28, 2019

Sorry for the super long delay here, I'd love to resurrect this PR would you have any time to rebase it?

@spencer516 spencer516 force-pushed the visit-transition-aborted branch 2 times, most recently from e214dd5 to 653801b Compare January 28, 2019 22:51
@spencer516
Copy link
Contributor Author

@rwjblue — just rebased.

However, this test is now failing for me in Safari :-P Chrome seems fine.

I wasn't able to dig too far into it, but when I disable the Ember 3.4 check in nextTickPromise(), the test is passing again.

Something something RSVP and Native Promises commingling === Unhappy Safari? This type of error feels like there's a new promise getting created somewhere that rejects that ends up not being a part of the promise chain where the catch is added in this PR...maybe?

@rwjblue
Copy link
Member

rwjblue commented Jan 28, 2019

This type of error feels like there's a new promise getting created somewhere that rejects that ends up not being a part of the promise chain where the catch is added in this PR...maybe?

Yes, sounds like exactly what is happening. I'll try to poke at it in the morning, and see if I can fix it up. Generally speaking, the fix here is correct we just need to entangle things properly to absorb the async in the redirect...

@rwjblue rwjblue self-assigned this Jan 28, 2019
@spencer516
Copy link
Contributor Author

Cool beans. I just made a change to get the 2.4 -> 2.12 scenarios to pass — and rather than aborting the transition, I just re-transition. Test now passes in safari, but that feels like a cheat.

Does transition.abort() create a rejected promise?

For what it's worth, the bubbles up errors test is also failing in Safari for, perhaps, a similar reason.

image

@rwjblue
Copy link
Member

rwjblue commented Jan 29, 2019

Does transition.abort() create a rejected promise?

Yes, aborting a transition is essentially the same as rejecting a promise.

@samselikoff
Copy link

We're running into this, any updates on this or workarounds for now?

@Turbo87 Turbo87 requested a review from rwjblue January 21, 2020 10:54
@Turbo87 Turbo87 added the bug label Jan 21, 2020
@patsy-issa
Copy link

Fwiw using redirect() to redirect instead of before/after/model does not cause visit to fail.

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

Successfully merging this pull request may close these issues.

6 participants