fix: wrap sync in try/catch and unlock mutex in a finally

This commit is contained in:
Derrick Hammer 2023-10-28 21:57:59 -04:00
parent 772d7eb21e
commit 09637948e7
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 10 deletions

View File

@ -170,6 +170,7 @@ export default abstract class BaseClient extends EventEmitter {
protected async _sync() {
await this.syncMutex.acquire();
try {
const currentPeriod = this.getCurrentPeriod();
if (currentPeriod > this._latestPeriod) {
if (!this.booted) {
@ -180,9 +181,12 @@ export default abstract class BaseClient extends EventEmitter {
this._latestPeriod = currentPeriod;
this.emit("synced");
}
} catch (e) {
console.log(e);
} finally {
this.syncMutex.release();
}
}
protected async subscribe(callback?: (ei: ExecutionInfo) => void) {
setInterval(async () => {