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

Helpers no longer work properly with scheduled run-loop queues in v2 #947

Closed
drewlee opened this issue Nov 24, 2020 · 4 comments · Fixed by #958
Closed

Helpers no longer work properly with scheduled run-loop queues in v2 #947

drewlee opened this issue Nov 24, 2020 · 4 comments · Fixed by #958

Comments

@drewlee
Copy link
Contributor

drewlee commented Nov 24, 2020

Test helpers, particularly render, seem to be out of sync with scheduled run-loop timers. This causes integration and acceptance tests to fail when a component schedules work on a queue (e.g., afterRender).

I've create a simple use case to demonstrate the issue. It consists of a basic component that schedules programmatic focus placement on an afterRender queue. It is very similar to some of the test failures I've noticed within our applications after upgrading to v2: https://github.com/drewlee/helpers-async.

There are two tests for the component. The first demonstrates the regression. What's particularly interesting is that running getSettledState() after render/click shows that the app still consists of pending timers and run-loop. The second test shows that a test can be coerced into passing by adding a settled waiter immediately after calling render. However, the app is still not quite settled after click resolves, so this seems to be symptomatic of all test helpers.

Screen Shot 2020-11-24 at 12 41 12 AM

I'm not exactly too sure whether the test helpers resolve prematurely before the run-loop stuff is complete, or whether the test helpers somehow trigger a new run loop. Especially given that the component's behavior is altered because the scheduled focus call ends up executing before the input is rendered (hence the Cannot read property 'focus' of null exception).

What I did find, is that removing this noop then callback in helper-hooks.js resolves the issue. I'm fairly certain that it's there for a good reason, so I'm somewhat hesitant for suggesting its removal as this may be a symptom of an issue related to Ember source, Backburner, or even RSVP. It seems very enigmatic for the stuff we're trying to avoid in this RSVP config though.

@drewlee
Copy link
Contributor Author

drewlee commented Nov 24, 2020

@scalvert this is the bug that I've been trying to pin down for a while. I've finally traced it down to the fact that all of the test failures were from components that schedule stuff on a run-loop queue.

@scalvert
Copy link
Contributor

@drewlee thanks for chasing this down. This is very odd behavior, and I wonder whether this further changed when we imported and used the _Promise util (which change to using an RSVP promise). I ask because the behavior is slightly different between RSVP's then vs. native then. That said, I do believe there's a subtle problem here that we need to dig into, and isn't immediately jumping out at me.

@rwjblue thoughts?

@rwjblue
Copy link
Member

rwjblue commented Dec 1, 2020

I think we've root caused what is going on here (@stefanpenner, @scalvert, and myself). I should have a PR up soon with an explanation.

@rwjblue
Copy link
Member

rwjblue commented Dec 2, 2020

#956 is a failing test PR for the underlying issue, with a detailed explanation of what is going on. Working on the fixes now.

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