AttributionParent.didDestroy() throws "Unknown callback" and drops the attribution allowlist's Remote Settings subscription
Categories
(Firefox :: New Tab Page, defect)
Tracking
()
People
(Reporter: florian, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [hnt])
AttributionParent in browser/extensions/newtab/lib/actors/NewTabAttributionParent.sys.mjs keeps its Remote Settings client in a module global, gAllowListClient, but binds its sync handler per instance in the constructor (this._onSync = this.onSync.bind(this)). Only the instance that creates the client subscribes, in retrieveAllowList(). Every other instance's didDestroy() hands RemoteSettingsClient.off a callback that was never registered, and off throws Error: Unknown callback.
Two consequences. The noisy one is an exception on every actor teardown: 5,465 of them from browser_attribution_actor.js alone in one CI day, the loudest error that test emits. The one that matters is that when the actor which is the subscriber is destroyed, the only sync listener goes with it, and retrieveAllowList() early-returns once gAllowListClient is set, so nothing re-subscribes. onSync is dead from then on and the allowlist stops following Remote Settings for the rest of the session.
The client is a module global that outlives every actor, so its subscription should be too: subscribe once alongside the client and leave didDestroy() out of it, or keep the bound handler next to the client and unsubscribe only when the client itself is dropped.
browser.newtabpage.activity-stream.discoverystream.attribution.enabled defaults to false, which is why this is S4: nothing ships with the feature on today.
test_onSync_updates_allowlist in browser_attribution_actor.js cannot catch either consequence. It calls parent.onSync() directly, so it never exercises the subscription, and it then overwrites the allowlist with setAllowListForTest([origin]) before asserting, so its assertion passes whether onSync worked or not. Repairing it belongs in the same patch as the fix.
Comment 1•2 months ago
|
||
| frontend-triage | ||
NewTabAttributionParent.sys.mjs unconditionally calls off("sync", this._onSync) with a per-instance bound handler, while only the instance that created the module-global gAllowListClient ever registered one at #118, and the client's private emitter hard-throws on a callback it cannot find in its listener array at RemoteSettingsClient.sys.mjs#76-87. When the subscribing instance is the one torn down the off succeeds instead, dropping the collection's only sync listener, and retrieveAllowList() never re-adds it because it early-returns while gAllowListClient is set.
Fix: Register one module-level sync handler alongside the client in retrieveAllowList() and drop didDestroy() entirely, keeping in mind the emitter's on does no deduplication. Repair test_onSync_updates_allowlist in browser_attribution_actor.js, whose setAllowListForTest([origin]) at #316 overwrites what onSync just wrote before the assertion reads it, and test_didDestroy_removes_listener at #332-360, which asserts the behavior being removed and only ever sees a stubbed off.
Suggested severity: S4. discoverystream.attribution.enabled defaults to false in ActivityStream.sys.mjs, so no shipping configuration loses allowlist updates today and the cost is CI error noise.
If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-wrong-file, ai-triage-wrong-cause, ai-triage-hallucination, ai-triage-out-of-scope, ai-triage-wrong-fix, ai-triage-shallow-fix.
Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.
Updated•28 days ago
|
Updated•28 days ago
|
Description
•