Closed Bug 1855545 Opened 1 year ago Closed 1 year ago

ShoppingUtils.init invokes NimbusFeatures.onUpdate in a loop

Categories

(Firefox :: Shopping, defect, P1)

defect

Tracking

()

VERIFIED FIXED
120 Branch
Tracking Status
firefox119 --- verified
firefox120 --- verified

People

(Reporter: jhirsch, Assigned: jhirsch)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fidefe-shopping])

Attachments

(1 file)

The ShoppingUtils.init code assumes that NimbusFeatures.shopping2023.onUpdate(callback) does not immediately invoke the callback when it is called, but it does. This leads to a "too much recursion" error on startup if enrolled in the beta test experiment, following these steps:

  1. In about:config set nimbus.debug to true
  2. open about:studies?optin_slug=review-checker-first-beta-119&optin_branch=treatment-a&optin_collection=nimbus-preview
  3. restart the browser
  4. look in the browser toolbox, observe a "Too much recursion" error calling the following functions in a loop:
InternalError: too much recursion
    _onFeatureUpdate resource://nimbus/lib/ExperimentStore.sys.mjs:389
    onUpdate resource://nimbus/ExperimentAPI.sys.mjs:472
    init resource:///modules/ShoppingUtils.sys.mjs:61
    onNimbusUpdate resource:///modules/ShoppingUtils.sys.mjs:43
    _onFeatureUpdate resource://nimbus/lib/ExperimentStore.sys.mjs:389
    onUpdate resource://nimbus/ExperimentAPI.sys.mjs:472
    init resource:///modules/ShoppingUtils.sys.mjs:61
    onNimbusUpdate resource:///modules/ShoppingUtils.sys.mjs:43
   ...

The problem here is that ShoppingUtils.init, inside the if (!this.registered) block, doesn't immediately set this.registered = true, but instead does:

   if (!this.registered) {
      lazy.NimbusFeatures.shopping2023.onUpdate(this.onNimbusUpdate);
      this._updateNimbusVariables();
      this.registered = true;
    }

It turns out that the onUpdate call immediately invokes this.onNimbusUpdate, which in turn calls ShoppingUtils.init, causing an infinite loop.

We can fix this by moving the this.registered = true line to the top of the block.

Assignee: nobody → jhirsch
Severity: -- → S2
Priority: -- → P1
Whiteboard: [fidefe-shopping]
Pushed by jhirsch@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ce22a7ec1ea0 Avoid an infinite loop in ShoppingUtils.init r=Mardak
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch

Comment on attachment 9355410 [details]
Bug 1855545: Avoid an infinite loop in ShoppingUtils.init r?mardak

Beta/Release Uplift Approval Request

  • User impact if declined: The shopping experiment will not initialize correctly, which will break some experiment telemetry.

  • Is this code covered by automated tests?: Yes

  • Has the fix been verified in Nightly?: No

  • Needs manual test from QE?: Yes

  • If yes, steps to reproduce: Opt in to the Nimbus experiment, then check for console errors and verify the telemetry is working.

  • in about:config, set nimbus.debug to true

  • load about:studies?optin_slug=review-checker-first-beta-119&optin_branch=treatment-a&optin_collection=nimbus-preview

  • restart the browser

  • visit a supported product page

  • check the value of the probes Glean.shoppingSettings.componentOptedOut, Glean.shoppingSettings.hasOnboarded, Glean.shoppingSettings.nimbusDisabledShopping have been set

  • List of other uplifts needed: None

  • Risk to taking this patch: Low

  • Why is the change risky/not risky? (and alternatives if risky): The shopping experiment will be limited to a very small audience.

This change is extremely small and confined to the shopping experiment initialization code.

  • String changes made/needed: No
  • Is Android affected?: No
Attachment #9355410 - Flags: approval-mozilla-beta?
Flags: qe-verify+
QA Whiteboard: [qa-triaged]

This issue is Verified as fixed in our latest Nightly build. We are being enroled and we no longer see the recursion error.

The telemetry pings we see in glean are :
"shopping.settings.component_opted_out": false,
"shopping.settings.nimbus_disabled_shopping": false,
"shopping.settings.has_onboarded": true,

Comment on attachment 9355410 [details]
Bug 1855545: Avoid an infinite loop in ShoppingUtils.init r?mardak

Approved for 119.0b4

Attachment #9355410 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Verified as fixed in 119.0b4.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triaged]
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: