-
Notifications
You must be signed in to change notification settings - Fork 310
Retry polling event queue always, with backoff #515
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
Conversation
This now has some conflicts; would you mind resolving those? |
Sure — done. |
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.
Thanks! This is an important fix. One small comment to check my understanding on something, then please merge at will.
lastRequest = request; | ||
final response = _nextResponse!; | ||
_nextResponse = null; | ||
lastRequest = request; |
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.
fake_api: Record premature requests, too, in lastRequest
Ah I think I see: a request is "premature" because it's made before its response has been prepared. So the difference is that in those cases (the cases where _nextResponse!
fails), the premature request will be recorded as lastRequest
, vs. not recorded.
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.
Yep, exactly.
This calls FakeAsync.flushMicrotasks on the FakeAsync that the tester is using. (In the AutomatedTestWidgetsFlutterBinding case, that is, i.e. the `flutter test` case, which is where the tester is already using a FakeAsync.) Seems like it'd be dubious to try to introduce our own FakeAsync (as with `awaitFakeAsync`) when already in another's zone. It's possible it would all work fine, but it seems complicated to have to think about.
This is pretty much transcribed straight from the JS implementation (and test) in zulip-mobile, in the files: src/utils/async.js src/utils/__tests__/async-test.js
This makes it a bit less close of a transcription from the JS version in zulip-mobile (which is why I didn't squash this into the previous commit), but I think a bit more idiomatic as Dart.
This seems like the least confusing behavior.
This has been a useful pattern for other test fakes and mocks.
All the tests still behave the same after this change, because any subsequent checks on `lastRequest` in each test look for a different value.
The new TODO comments are all things that we don't do today in zulip-mobile, and haven't been aware of causing problems for people. So there's no rush to do them here. Fixes: zulip#184
Merged. Thanks for the review! |
Fixes: #184
Along the way, add some infrastructure to help us better write tests for asynchronous code, and in particular to better use
package:fake_async
.