A common problem with nyxx in previous versions has been that calling client.close() will return a future that completes, but the process will stay alive as the library was still doing some invisible async work in the background. In other words, client.close() didn't correctly dispose of all pending async operations.
This is still the case now, this time because of rate limits - the timers created through uses of Future.delayed kept the program alive until their callback was triggered, at which point nyxx realizes the client is closed and aborts the task. This PR fixes this issue by making uses of timers explicit and cancelling them when needed.
This PR also adds a test that ensures client.close():
1) is quick, and does not hang
2) closes any streams/completes any futures returned by methods on the client
3) does not leave any hidden async operations running
Type of change
[x] Bug fix (non-breaking change which fixes an issue)
Checklist:
[x] Ran dart analyze or make analyze and fixed all issues
[x] Ran dart format --set-exit-if-changed -l 160 ./lib or make format and fixed all issues
[x] I have performed a self-review of my own code
[x] I have commented my code, particularly in hard-to-understand areas
[x] I have made corresponding changes to the documentation
[x] I have added tests that prove my fix is effective or that my feature works
Description
A common problem with nyxx in previous versions has been that calling
client.close()
will return a future that completes, but the process will stay alive as the library was still doing some invisible async work in the background. In other words,client.close()
didn't correctly dispose of all pending async operations.This is still the case now, this time because of rate limits - the timers created through uses of
Future.delayed
kept the program alive until their callback was triggered, at which point nyxx realizes the client is closed and aborts the task. This PR fixes this issue by making uses of timers explicit and cancelling them when needed.This PR also adds a test that ensures
client.close()
: 1) is quick, and does not hang 2) closes any streams/completes any futures returned by methods on the client 3) does not leave any hidden async operations runningType of change
Checklist:
dart analyze
ormake analyze
and fixed all issuesdart format --set-exit-if-changed -l 160 ./lib
ormake format
and fixed all issues