zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.23k stars 613 forks source link

It does not seem that you are canceling timer on `stopPolling` operation. #1360

Open vasilich6107 opened 1 year ago

vasilich6107 commented 1 year ago

Describe the issue When writing test for queries with polling it fails with A Timer is still pending even after the widget tree was disposed. it does not seem that void stopPollingQuery(String queryId) { method actually stops the timer.

To Reproduce (MUST BE PROVIDED)

Write a test for the widget that is querying with poll interval

Expected behavior The timer should be stopped if there is no more queries polling.

vasilich6107 commented 1 year ago

I see this comment

// We don't remove queries from intervalQueries immediately in
// stopPollingQuery so that we can keep the timer consistent when queries
// are removed and replaced, and to avoid quadratic behavior when stopping
// many queries.

Could you provide a workaround on writing tests?

vincenzopalazzo commented 1 year ago

Mh I did not write this code, so I should check if this is true and required for me! I will take a look during the holidays