Skip to content

Commit 3234ed6

Browse files
committed
fix(class/eventManagement/dispatcher): return a promise in interval ctx
1 parent 2f0cf44 commit 3234ed6

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/class/eventManagement/dispatcher.class.ts

+15-17
Original file line numberDiff line numberDiff line change
@@ -263,30 +263,28 @@ export class Dispatcher<T extends GenericEvent = GenericEvent> extends EventEmit
263263
}
264264
});
265265

266-
this.resolveTransactionsInterval = setInterval(async() => {
266+
this.resolveTransactionsInterval = setInterval(() => {
267267
if (!this.isWorking) {
268268
return;
269269
}
270270

271-
try {
272-
await this.transactionHandler.resolveTransactions();
273-
}
274-
catch (error) {
275-
this.logger.error({ error: error.stack }, "Failed at resolving transactions");
276-
}
271+
new Promise((resolve) => {
272+
this.transactionHandler.resolveTransactions()
273+
.then(() => resolve(null))
274+
.catch((error) => this.logger.error({ error: error.stack }, "Failed at resolving transactions"));
275+
});
277276
}, options.checkTransactionInterval ?? RESOLVE_TRANSACTION_INTERVAL).unref();
278277

279-
this.pingIntervalTimer = setInterval(async() => {
280-
try {
281-
if (!this.isWorking) {
282-
return;
283-
}
284-
285-
await this.ping();
286-
}
287-
catch (error) {
288-
this.logger.error({ error: error.stack }, "Failed sending pings");
278+
this.pingIntervalTimer = setInterval(() => {
279+
if (!this.isWorking) {
280+
return;
289281
}
282+
283+
new Promise((resolve) => {
284+
this.ping()
285+
.then(() => resolve(null))
286+
.catch((error) => this.logger.error({ error: error.stack }, "Failed sending pings"));
287+
});
290288
}, this.pingInterval).unref();
291289

292290
this.checkLastActivityIntervalTimer = setInterval(async() => {

0 commit comments

Comments
 (0)