question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Waiter not registered for some async calls

See original GitHub issue

When we face this issue:

There are some scenarios when settled does not wait for some async calls:

  • when there is a watched query and we refetch the query;
  • when there is a watched query and we fetch more data;
  • when we send a mutation with the option refetchQueries;

We just increment the ongoing counter for the first fetch. When we call refetch, fetchMore or set refetchQueries when sending a mutation, we do not register those ongoing requests.

How this is solved in my app

Query Manager

import QueryManager from 'ember-apollo-client/apollo/query-manager';

export default QueryManager.extend({
  refetch(opts, observable) {
    return this.apollo.refetch(opts, observable);
  },

  fetchMore(opts, observable) {
    return this.apollo.fetchMore(opts, observable);
  }
});

Service

import ApolloService from 'ember-apollo-client/services/apollo';
import QueryManager from 'my-app/apollo/query-manager';

export default ApolloService.extend({
  createQueryManager() {
    return QueryManager.create({ apollo: this });
  },

  refetch(opts, observable) {
    return this._waitFor(observable.refetch(opts));
  },

  fetchMore(opts, observable) {
    return this._waitFor(observable.fetchMore(opts));
  },

  mutate(opts, resultKey) {
    if (Ember.testing) {
      opts.awaitRefetchQueries = true;
    }

    return this._super(opts, resultKey);
  }
});

Examples of how we use those functions:

  • fetchMore for pagination
  • refetch for searches
  • mutation with refetchQueries for deletes

Disclaimer

We are not mocking our API. Our API has a sandbox server for tests. Maybe mocks are obfuscating this issue.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:16 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
xtagoncommented, Sep 28, 2019

@viniciussbs Your solution is working for me, thank you 😃

1reaction
viniciussbscommented, Apr 22, 2019

@bgentry Any input on this one?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async End<Method> not called in WCF - Stack Overflow
I have the following situation: My WCF service allows a client to register to wait for some event. The waiting is asynchronous on...
Read more >
Migrate to ember-test-waiters · Issue #297 · ember-graphql/ember ...
We have built our own solution for registering test waiters with ember, but we should take a look at ... Waiter not registered...
Read more >
Synchronization Primitives — Python 3.11.1 documentation
methods of these synchronization primitives do not accept the timeout argument; use the asyncio.wait_for() function to perform operations with timeouts.
Read more >
Concepts - Oracle Help Center
To make asynchronous calls, create an instance of the asynchronous client. ... A waiter can be invoked in both a blocking or a...
Read more >
Async, Await, and ConfigureAwait – Oh My! | Core BTS Blog
If there is a possibility that a synchronous call could call your asynchronous method, you end up being forced to put .ConfigureAwait(false) on ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found