tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 7f239a90c98674e59c153eef3ff1122ed4ce3270
parent 43c55af65c60a2cfedeb45275256536a12937839
Author: Beth Rennie <beth@brennie.ca>
Date:   Sat,  1 Nov 2025 12:50:15 +0000

Bug 1972647 - Suppress log spam when the RS collections have not yet synced r=nimbus-reviewers,relud

Differential Revision: https://phabricator.services.mozilla.com/D270855

Diffstat:
Mtoolkit/components/nimbus/lib/RemoteSettingsExperimentLoader.sys.mjs | 33+++++++++++++++++++++++++--------
Mtoolkit/components/nimbus/lib/Telemetry.sys.mjs | 1+
2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/toolkit/components/nimbus/lib/RemoteSettingsExperimentLoader.sys.mjs b/toolkit/components/nimbus/lib/RemoteSettingsExperimentLoader.sys.mjs @@ -20,6 +20,8 @@ ChromeUtils.defineESModuleGetters(lazy, { NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs", NimbusTelemetry: "resource://nimbus/lib/Telemetry.sys.mjs", RemoteSettings: "resource://services-settings/remote-settings.sys.mjs", + RemoteSettingsClient: + "resource://services-settings/RemoteSettingsClient.sys.mjs", TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs", recordTargetingContext: "resource://nimbus/lib/TargetingContextRecorder.sys.mjs", @@ -490,8 +492,6 @@ export class RemoteSettingsExperimentLoader { * @returns {Promise<object[]>} The recipes from Remote Settings. * * @throws {RemoteSettingsSyncError} - * @throws {BackwardsSyncError} - * @throws {InvalidLastModifiedError} */ async getRecipesFromAllCollections({ forceSync = false, trigger } = {}) { try { @@ -548,9 +548,19 @@ export class RemoteSettingsExperimentLoader { return recipes; } catch (e) { - lazy.log.error("Failed to retrieve recipes from Remote Settings", e); + let suppressLog = false; if (e instanceof RemoteSettingsSyncError) { + // Suppress console errors about the RS database not yet being synced. + // This spams logs in tests where the RS client does not have a valid + // URL to sync with. + if ( + e.reason === + lazy.NimbusTelemetry.RemoteSettingsSyncErrorReason.NOT_YET_SYNCED + ) { + suppressLog = true; + } + lazy.NimbusTelemetry.recordRemoteSettingsSyncError( e.collectionName, e.reason, @@ -558,6 +568,10 @@ export class RemoteSettingsExperimentLoader { ); } + if (!suppressLog) { + lazy.log.error("Failed to retrieve recipes from Remote Settings", e); + } + throw e; } } @@ -596,11 +610,14 @@ export class RemoteSettingsExperimentLoader { emptyListFallback: false, // Throw instead of returning an empty list. }); } catch (e) { - throw new RemoteSettingsSyncError( - client.collectionName, - lazy.NimbusTelemetry.RemoteSettingsSyncErrorReason.GET_EXCEPTION, - { cause: e } - ); + const reason = + e instanceof lazy.RemoteSettingsClient.EmptyDatabaseError + ? lazy.NimbusTelemetry.RemoteSettingsSyncErrorReason.NOT_YET_SYNCED + : lazy.NimbusTelemetry.RemoteSettingsSyncErrorReason.GET_EXCEPTION; + + throw new RemoteSettingsSyncError(client.collectionName, reason, { + cause: e, + }); } if (!Array.isArray(recipes)) { diff --git a/toolkit/components/nimbus/lib/Telemetry.sys.mjs b/toolkit/components/nimbus/lib/Telemetry.sys.mjs @@ -51,6 +51,7 @@ const RemoteSettingsSyncErrorReason = Object.freeze({ INVALID_DATA: "invalid-data", INVALID_LAST_MODIFIED: "invalid-last-modified", LAST_MODIFIED_EXCEPTION: "last-modified-exception", + NOT_YET_SYNCED: "not-yet-synced", NULL_LAST_MODIFIED: "null-last-modified", });