From 9946f612963a2ab5be97749f9a76a2d8ca3ac8e5 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Thu, 4 Sep 2025 12:40:37 -0400 Subject: [PATCH] fix(notifications): [PM-25424] Fix unnecessary quick reconnect * Ensure we don't reconnect on feature flag emissions of the same value * Harden notification processing * Do error for both --- .../default-server-notifications.service.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libs/common/src/platform/server-notifications/internal/default-server-notifications.service.ts b/libs/common/src/platform/server-notifications/internal/default-server-notifications.service.ts index e8ac93dc61f..6d0728ab65d 100644 --- a/libs/common/src/platform/server-notifications/internal/default-server-notifications.service.ts +++ b/libs/common/src/platform/server-notifications/internal/default-server-notifications.service.ts @@ -172,6 +172,7 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer private hasAccessToken$(userId: UserId) { return this.configService.getFeatureFlag$(FeatureFlag.PushNotificationsWhenLocked).pipe( + distinctUntilChanged(), switchMap((featureFlagEnabled) => { if (featureFlagEnabled) { return this.authService.authStatusFor$(userId).pipe( @@ -305,11 +306,23 @@ export class DefaultServerNotificationsService implements ServerNotificationsSer startListening() { return this.notifications$ .pipe( - mergeMap(async ([notification, userId]) => this.processNotification(notification, userId)), + mergeMap(async ([notification, userId]) => { + try { + await this.processNotification(notification, userId); + } catch (err: unknown) { + this.logService.error( + `Problem processing notification of type ${notification.type}`, + err, + ); + } + }), ) .subscribe({ - error: (e: unknown) => - this.logService.warning("Error in server notifications$ observable", e), + error: (err: unknown) => + this.logService.error( + "Fatal error in server notifications$ observable, notifications won't be recieved anymore.", + err, + ), }); }