Heads up about new major version of set-interval-async
Opened this issue · 1 comments
Hi.
A new version of set-interval-async is available with improvements on error handling and including a bug fix. You may see the changes in more detail in the release notes.
I'm reaching out because I noticed an instance of the following pattern in your project, which may lead to undesired results:
const timer = setIntervalAsync(async () => {
// ...
if (/* some condition */) {
await clearIntervalAsync(timer);
}
}, interval);
The code above generates a chaining promise cycle which never resolves, because:
await clearIntervalAsync(timer)
will not resolve until the last execution has finished, AND- the last execution will not finish until
await clearIntervalAsync(timer)
has been resolved.
Simply not awaiting clearIntervalAsync
may be enough to avoid this issue, but the right solution will depend on your application's requirements. This didn't surface earlier due to the bug in set-interval-async that has now been fixed in the latest major version.
Best,
Emilio
@ealmansi Thank you for bringing this up to my attention. I'm not working on and/or using this project anytime soon so I don't have any plans of fixing this (clearIntervalAsync
is used in the cleanup phase of this bot and it's not directly coupled with setIntervalAsync
so it's not a huge priority to fix).
However, for anyone else reading this, feel free to submit a PR!