ember-cli / ember-cli/ember-fetch

Flickering test failures w/ Ember 2.18.2 & 3.4.7

Open
#204 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
176
Forks
78
PR merge metrics
No merged PRs in 30d

Description

This is a follow up on comments in #25 [starting here](https://github.com/ember-cli/ember-fetch/pull/25#issuecomment-424799025).

## Background

In preparation to upgrading from Ember `2.18.2` to `3.4.7`, I've been refactoring a fairly complex custom `ajax` service that my app uses to rely on `ember-fetch` instead of `ic-ajax` (`ember-ajax` has its own service implementation that was in conflict, so opted to move all the way up to `fetch` based solution).

Everything in development mode seemed to be working fine in `2.18.2`, but when I ran my full test suite (modern `3.x` testing style already migrated), I began to get a number of failures due to tests not waiting for `fetch` requests to finish as expected by `await` calls.

## What I have observed

In `2.18.2` with `ember-fetch` `6.3.1`, `ember-test-helpers` `1.1.0`, and `ember-qunit` `4.2.0`:

* if I reran the tests individually, most tests would pass as expected
* adding `await settled()` calls at a point before the test failure would _most times_ alleviate the test failure when running full suite (after doing this several places, I gave up on this before adding tons of these allover the whole suite)
* `ember-fetch` `registerWaiter` seems to be working as designed, but is not enough - I added logging to see if the waiter function was being set up and called as well as the decrementing and they were

It was almost like there was leak somewhere...

A coworker wondered if anything would be different if I tried things under Ember `3.4.7`. Unfortunately, the problem was still there. However...

## What allows the tests to run as expected in Ember `3.4.7`, but not `2.18.2`

Under Ember `3.4.7` when I changed `ember-cli-build.js` to the following, the test suite passed!

```JavaScript
let app = new EmberApp(defaults, {
// tests: false,
'ember-fetch': {
preferNative: true // later added logic here to only be true in test env
},
...
```

However, when I circled back and tried this with `2.18.2`, I got different failures, e.g. `Promise rejected during "Help with a ongoing cost": Cannot read property 'error' of undefined`, that I assume are related to native promises not being supported in the same way as later Ember 3.x releases.

Since my ultimate goal is to be able to upgrade away from `2.18.2`, I'm personally unblocked, but this does seem like an issue with the polyfil either in `ember-fetch` or possibly upstream.

(@viniciussbs hopefully my workaround helps you, too)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.