From c08494eea6acfed2266a7a5b22d9e943cde91f2a Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Wed, 26 Jun 2024 09:35:03 -0400 Subject: [PATCH] fix(youtube): Catch auth issues that occur during polling #158 --- src/backend/sources/AbstractSource.ts | 4 ++++ src/backend/tasks/heartbeatSources.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/sources/AbstractSource.ts b/src/backend/sources/AbstractSource.ts index ef076703..a4f80576 100644 --- a/src/backend/sources/AbstractSource.ts +++ b/src/backend/sources/AbstractSource.ts @@ -434,6 +434,10 @@ export default abstract class AbstractSource extends AbstractComponent implement } catch (e) { this.logger.error('Error occurred while polling'); this.logger.error(e); + if(e.message.includes('Status code: 401')) { + this.authed = false; + this.authFailure = true; + } this.emitEvent('statusChange', {status: 'Idle'}); this.polling = false; throw e; diff --git a/src/backend/tasks/heartbeatSources.ts b/src/backend/tasks/heartbeatSources.ts index 50ac72f0..43b645bd 100644 --- a/src/backend/tasks/heartbeatSources.ts +++ b/src/backend/tasks/heartbeatSources.ts @@ -21,7 +21,7 @@ export const createHeartbeatSourcesTask = (sources: ScrobbleSources, parentLogge } if (source.canPoll && !source.polling && (!source.authGated() || source.canTryAuth())) { source.logger.info('Should be polling! Attempting to restart polling...', {leaf: 'Heartbeat'}); - source.poll(); + source.poll().catch(e => logger.error(e)); return 1; } }