diff --git a/src/backend/scrobblers/AbstractScrobbleClient.ts b/src/backend/scrobblers/AbstractScrobbleClient.ts index 056adccf..24facdb0 100644 --- a/src/backend/scrobblers/AbstractScrobbleClient.ts +++ b/src/backend/scrobblers/AbstractScrobbleClient.ts @@ -228,6 +228,7 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i [Symbol.dispose]() { this.scheduler.stop(); for(const job of this.scheduler.getAllJobs()) { + job.stop(); this.scheduler.removeById(job.id); } } @@ -259,7 +260,9 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i } ), {id: 'heartbeat'})); } else { - this.logger.verbose('Heartbeat task is already added to scheduler.'); + this.logger.verbose('Heartbeat task is already added to scheduler, running immediately instead'); + const j = this.scheduler.getById('heartbeat') as SimpleIntervalJob; + j.start(); } this.initializeNowPlayingSchedule(); @@ -352,6 +355,7 @@ export default abstract class AbstractScrobbleClient extends AbstractComponent i try { this.scheduler.stop(); for (const job of this.scheduler.getAllJobs()) { + job.stop(); this.scheduler.removeById(job.id); } await this.tryStopScrobbling(opts.reason); diff --git a/src/backend/sources/AbstractSource.ts b/src/backend/sources/AbstractSource.ts index 39381e9d..ce2a88fa 100644 --- a/src/backend/sources/AbstractSource.ts +++ b/src/backend/sources/AbstractSource.ts @@ -137,6 +137,13 @@ export default abstract class AbstractSource extends AbstractComponent implement } + [Symbol.dispose]() { + this.scheduler.stop(); + for(const job of this.scheduler.getAllJobs()) { + job.stop(); + this.scheduler.removeById(job.id); + } + } async [Symbol.asyncDispose]() { try { await this.stop({ reason: 'Instance is being destroyed' }); @@ -165,7 +172,9 @@ export default abstract class AbstractSource extends AbstractComponent implement } ), {id: 'heartbeat'})); } else { - this.logger.warn('Heartbeat task is already added to scheduler.'); + this.logger.verbose('Heartbeat task is already added to scheduler, running immediately instead'); + const j = this.scheduler.getById('heartbeat') as SimpleIntervalJob; + j.start(); } } @@ -236,6 +245,7 @@ export default abstract class AbstractSource extends AbstractComponent implement } this.scheduler.stop(); for (const job of this.scheduler.getAllJobs()) { + job.stop(); this.scheduler.removeById(job.id); } this.setStatus('Stopped');