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

Setting coalesceFindRequests to true may break testing #4569

Closed
GRardB opened this issue Oct 6, 2016 · 4 comments
Closed

Setting coalesceFindRequests to true may break testing #4569

GRardB opened this issue Oct 6, 2016 · 4 comments

Comments

@GRardB
Copy link

GRardB commented Oct 6, 2016

Hey!

I ran into a bug recently, which @mixonic helped me with. Essentially, enabling coalesceFindRequests caused one of my acceptance tests to hang.

The test:

test('', function(assert) {
  // ember-cli-mirage
  server.createList('invitation', 5, {
    accepted: true,
    group: server.create('group'),
    member: this.user,
  });

  visit('/');

  andThen(() => {
    // the test (irrelevant)
  });
});

The offending code:

afterModel: function(model) {
  if (model) {
    return model.user.get('invitations').then((invitations) => (
      Ember.RSVP.all(
        invitations.map((invitation) => (
          invitation.get('group').then(group => {
            return group.reload(); // makes the test hang
          })
        ))
      )
    ));
  }
},

I have a Twiddle which shows the rest of the relevant code (minus the adapter and the test), but I suspect it's not really necessary.

From our email exchange, I'll quote:

Apparently, when you coalesceFindRequests, the AJAX request isn’t immediately started, thus when the waiter checks it doesn’t see any requests in flight and presumes that things are “settled”. The test is permitted, incorrectly, to continue.

Disabling coalesceFindRequests allows the test to run!

At this point, it's probably best for Matthew to chime in with his knowledge and suggestions for how to fix the issue 😁

@mixonic
Copy link
Member

mixonic commented Oct 6, 2016

@fivetanley we talked about adding a waiter for ember-data separately from this, but it seems coalesceFindRequests is another spot where ember-data should be expressing waiting itself instead of relying on the jQuery ajax system.

@broerse
Copy link

broerse commented Jan 4, 2017

Perhaps it is related to a bug with _findMany See: #4463

@jalcine
Copy link

jalcine commented Oct 30, 2017

Any update on this? Looks like progress stalled on #4463.

@runspired
Copy link
Contributor

runspired commented Apr 21, 2018

We've added a test-waiter #5422 :)

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

No branches or pull requests

5 participants