-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
Ensure @ember/test-helpers
promise based helpers never create a run loop for resolving the promise.
#958
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rwjblue
force-pushed
the
avoid-rsvp-promises-internally
branch
from
December 4, 2020 17:13
09968d6
to
04495b7
Compare
cc/ @drewlee |
rwjblue
changed the title
Ensure Dec 4, 2020
runHooks
results in isSettled()
being false when resolved@ember/test-helpers
promise based helpers never create a run loop for resolving the promise.
rwjblue
force-pushed
the
avoid-rsvp-promises-internally
branch
from
December 4, 2020 17:20
04495b7
to
46439cf
Compare
scalvert
approved these changes
Dec 4, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks 👍 and is largely what was discussed. Thanks!
This commit introduces a number of (currently failing) tests that are attempting to confirm that after running various public methods that we are in a settled state. The tests all fail at the moment, because the `Promise.all` that is done wihtin `runHooks` does **not** go through our custom `RSVP.configure('async', fn)`. This is because the `async` hook in RSVP only receives a second argument (the `promise` argument) in some circumstances but not in the case where the parent promise is not in the pending state ([this branch in RSVP](https://github.com/tildeio/rsvp.js/blob/429ade2379dfbfb6e2c6f453b4aeb642515dbb74/lib/rsvp/then.js#L28-L33)). `RSVP.Promise.all([undefined, undefined])` is considered settled immediately, so `RSVP.Promise.all().then(fn)` returns a promise that will **not** get our custom promise resolution scheduling. Since our custom scheduling is not being used here, the normal `RSVP` integration is used which means that the promise will resolve in the `actions` queue of the run loop. Ultimately, this is why `isSettled()` returns false when `await runHooks(...)` completes: a run loop was started in order to resolve the `runHooks` promise, but it has not completed yet.
We no longer support Ember < 3.8, so this can be safely removed.
* Removes `RSVP.configure('async', fn)` override * Updates internals to use native promises where available * Leaves IE11 support broken (will be fixed in a follow up commit) * Exports `Promise` from `-utils` (instead of `_Promise`)
Ember should be ensuring an instance on its own here (the act of setting outletState should ensureInstance, since we know we need to render), but it is not. This really needs to be fixed in Ember (and then we can guard this `ensureInstance` call for newer Ember versions).
This ensures that we support environments without a native `Promise` but still avoid using the manually configured `Ember.RSVP` runloop integration.
This ensures that when folks do something like this: ```js if (typeof Promise === 'undefined') { self.Promise = Ember.RSVP.Promise; } ``` We still use a Promise that is **not** configured on the run loop.
Fixes issues with IE11 compat.
rwjblue
force-pushed
the
avoid-rsvp-promises-internally
branch
2 times, most recently
from
December 4, 2020 21:01
936e6c9
to
53b1c61
Compare
This is normally handled for folks by ember-qunit, but @ember/test-helpers has to handle it for itself. We need to get this fixed over in ember-cli...
rwjblue
force-pushed
the
avoid-rsvp-promises-internally
branch
from
December 4, 2020 21:05
53b1c61
to
8c33a27
Compare
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This removes the custom
RSVP.configure('async', fn)
that we have used for a while (introduced in 0da35f4) in favor of using nativePromise
whenever possible and falling back to a separately loaded (viaember-auto-import
)es6-promise
polyfill when native Promise is not available.This does increase the overall size of
assets/test-support.js
by ~ 27kb (see the es6-promise README), but since that doesn't really affect any production application situations it should be fine. Once we drop support for browsers that do not have a nativePromise
we can removeember-auto-import
and oures6-promise
polyfill.In order to test that this implementation functions properly in IE11, I had to get the testing infrastructure back into a state where IE11 can run tests. That required a number of changes:
Closes #956
Fixes #947