commit 4ce984884b6a1e75d5395cc77eff68079851671b
parent 1131839caa75339b375d8997ae46840a69aa4f78
Author: Ben Dean-Kawamura <bdk@mozilla.com>
Date: Mon, 3 Nov 2025 21:01:36 +0000
Bug 1996811 - Check for shutdown before registering `uninit`, r=nanj
Differential Revision: https://phabricator.services.mozilla.com/D270329
Diffstat:
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/toolkit/components/contentrelevancy/ContentRelevancyManager.sys.mjs b/toolkit/components/contentrelevancy/ContentRelevancyManager.sys.mjs
@@ -106,12 +106,24 @@ class RelevancyManager {
lazy.NimbusFeatures.contentRelevancy.onUpdate(this._nimbusUpdateCallback);
this.#initialized = true;
- // Interrupt sooner prior to the `profile-before-change` phase to allow
- // all the in-progress IOs to exit.
- lazy.AsyncShutdown.profileChangeTeardown.addBlocker(
- "ContentRelevancyManager: Interrupt IO operations on relevancy store",
- () => this.uninit()
- );
+ if (
+ Services.startup.isInOrBeyondShutdownPhase(
+ Ci.nsIAppStartup.SHUTDOWN_PHASE_APPSHUTDOWNCONFIRMED
+ )
+ ) {
+ // Corner case, where we're already in the shutdown phase while being constructed. In this
+ // case, uninitialize immediately to deregister callback handlers
+ // (#https://bugzilla.mozilla.org/show_bug.cgi?id=1990569#c11)
+ this.uninit();
+ } else {
+ // If we're not in the above corner case, then register a shutdown blocker to uninitialize.
+ // Interrupt sooner prior to the `profile-before-change` phase to allow
+ // all the in-progress IOs to exit.
+ lazy.AsyncShutdown.profileChangeTeardown.addBlocker(
+ "ContentRelevancyManager: Interrupt IO operations on relevancy store",
+ () => this.uninit()
+ );
+ }
}
uninit() {