henry pushed to branch tor-browser-149.0a1-16.0-2 at The Tor Project / Applications / Tor Browser Commits: edf9758a by Henry Wilkes at 2026-03-24T14:48:48+00:00 fixup! TB 40933: Add tor-launcher functionality TB 44753: Drop TorProvider.isBootstrapDone. - - - - - 3dac4f13 by Henry Wilkes at 2026-03-24T14:48:50+00:00 fixup! TB 41668: Tweaks to the Base Browser updater for Tor Browser TB 44753: Use TorConnect rather than TorProvider to determine if we are bootstrapped. This avoids a direct and async call to the provider. We also add a safety check to determine whether the bootstrap has already called before adding the listener. - - - - - 2 changed files: - toolkit/components/tor-launcher/TorProvider.sys.mjs - toolkit/mozapps/update/UpdateService.sys.mjs Changes: ===================================== toolkit/components/tor-launcher/TorProvider.sys.mjs ===================================== @@ -137,7 +137,6 @@ export class TorProvider { */ #socksSettings = null; - #isBootstrapDone = false; /** * Keep the last warning to avoid broadcasting an async warning if it is the * same one as the last broadcast. @@ -510,10 +509,6 @@ export class TorProvider { return TorLauncherUtil.shouldStartAndOwnTor; } - get isBootstrapDone() { - return this.#isBootstrapDone; - } - /** * TODO: Rename to isReady once we remove finish the migration. * @@ -883,7 +878,6 @@ export class TorProvider { "Requested to close an already closed control port connection" ); } - this.#isBootstrapDone = false; this.#lastWarning = {}; } @@ -1005,12 +999,9 @@ export class TorProvider { Services.obs.notifyObservers(statusObj, TorProviderTopics.BootstrapStatus); if (statusObj.PROGRESS === 100) { - this.#isBootstrapDone = true; return; } - this.#isBootstrapDone = false; - // Can TYPE ever be ERR for STATUS_CLIENT? if ( isNotification && ===================================== toolkit/mozapps/update/UpdateService.sys.mjs ===================================== @@ -22,7 +22,9 @@ ChromeUtils.defineESModuleGetters(lazy, { AddonManager: "resource://gre/modules/AddonManager.sys.mjs", AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs", DeferredTask: "resource://gre/modules/DeferredTask.sys.mjs", - TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs", + TorConnect: "resource://gre/modules/TorConnect.sys.mjs", + TorConnectStage: "resource://gre/modules/TorConnect.sys.mjs", + TorConnectTopics: "resource://gre/modules/TorConnect.sys.mjs", UpdateLog: "resource://gre/modules/UpdateLog.sys.mjs", UpdateUtils: "resource://gre/modules/UpdateUtils.sys.mjs", WindowsRegistry: "resource://gre/modules/WindowsRegistry.sys.mjs", @@ -372,15 +374,6 @@ export function testResetIsBackgroundTaskMode() { resetIsBackgroundTaskMode(); } -async function _shouldRegisterBootstrapObserver() { - try { - const provider = await lazy.TorProviderBuilder.build(); - return !provider.isBootstrapDone && provider.ownsTorDaemon; - } catch { - return false; - } -} - /** * Changes `nsIApplicationUpdateService.currentState` and causes * `nsIApplicationUpdateService.stateTransition` to resolve. @@ -2831,7 +2824,7 @@ export class UpdateService { case "network:offline-status-changed": await this._offlineStatusChanged(data); break; - case "torconnect:bootstrap-complete": + case lazy.TorConnectTopics.BootstrapComplete: this._bootstrapComplete(); break; case "quit-application": @@ -3447,7 +3440,36 @@ export class UpdateService { await this._attemptResume(); } + /** + * Whether we should wait for the Tor bootstrap event to try again because we + * are not yet bootstrapped. + * + * If the browser does not monitor the Tor connection state, this will return + * `false` since the event will never fire. + * + * @returns {boolean} - Whether we should wait for the bootstrap event. + */ + _shouldRegisterBootstrapObserver() { + return ( + lazy.TorConnect.enabled && + lazy.TorConnect.stageName !== lazy.TorConnectStage.Bootstrapped + ); + } + + /** + * Wait for the Tor connection to be bootstrapped before trying again. + */ _registerBootstrapObserver() { + // Double check that we haven't since become bootstrapped between the call + // to _shouldRegisterBootstrapObserver and _registerBootstrapObserver, which + // may be delayed. If so, we do not wait for the BootstrapComplete signal + // since it has already fired. + if (lazy.TorConnect.stageName === lazy.TorConnectStage.Bootstrapped) { + LOG("UpdateService:_registerBootstrapObserver - already bootstrapped"); + this._bootstrapComplete(); + return; + } + if (this._registeredBootstrapObserver) { LOG( "UpdateService:_registerBootstrapObserver - observer already registered" @@ -3460,13 +3482,22 @@ export class UpdateService { "to be complete, then forcing another check" ); - Services.obs.addObserver(this, "torconnect:bootstrap-complete"); + Services.obs.addObserver(this, lazy.TorConnectTopics.BootstrapComplete); this._registeredBootstrapObserver = true; } + /** + * Called when the Tor connection becomes bootstrapped. This will trigger a + * retry. + */ _bootstrapComplete() { - Services.obs.removeObserver(this, "torconnect:bootstrap-complete"); - this._registeredBootstrapObserver = false; + if (this._registeredBootstrapObserver) { + Services.obs.removeObserver( + this, + lazy.TorConnectTopics.BootstrapComplete + ); + this._registeredBootstrapObserver = false; + } LOG( "UpdateService:_bootstrapComplete - bootstrapping complete, forcing " + @@ -3511,7 +3542,7 @@ export class UpdateService { return; } else if ( update.errorCode === PROXY_SERVER_CONNECTION_REFUSED && - (await _shouldRegisterBootstrapObserver()) + this._shouldRegisterBootstrapObserver() ) { // Register boostrap observer to try again, but only when we own the // tor process. @@ -7105,7 +7136,7 @@ class Downloader { deleteActiveUpdate = false; } else if ( status === PROXY_SERVER_CONNECTION_REFUSED && - (await _shouldRegisterBootstrapObserver()) + this.updateService._shouldRegisterBootstrapObserver() ) { // Register a bootstrap observer to try again. // The bootstrap observer will continue the incremental download by View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/abb0be2... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/abb0be2... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help
participants (1)
-
henry (@henry)