Closed Bug 1737928 Opened 3 years ago Closed 3 years ago

Add a timeout mechanism for quick suggest fetches from Merino

Categories

(Firefox :: Address Bar, task, P1)

task
Points:
3

Tracking

()

RESOLVED FIXED
96 Branch
Iteration:
96.1 - Nov 1 - Nov 14
Tracking Status
firefox94 + fixed
firefox95 --- fixed
firefox96 --- fixed

People

(Reporter: adw, Assigned: adw)

References

Details

Attachments

(1 file)

We should add a timeout mechanism to Merino fetches and fall back to remote settings on timeout.

We use fetch to send requests. The fetch spec doesn't define a timeout, the MDN docs don't mention one, and there doesn't seem to be an explicit timeout in the Gecko implementation. I imagine somewhere in Necko there's a timeout but it's probably large, and I haven't had time to test it yet.

Judging by some googling, the typical way of implementing a timeout using fetch is just a setTimeout plus AbortController. We already have an abort controller used for canceling the fetch when the query is canceled.

I talked about this with Nan and mythmon. I think we have three options vis-a-vis timeouts and our two sources of suggestions, remote settings and Merino, assuming we still start the fetches from both sources concurrently:

  1. Race to the highest-priority suggestion: As soon as the RS fetch finishes, add its suggestion if the Merino suggestion hasn't already been added. As soon as the Merino fetch finishes, add its suggestion unconditionally. The downside is that the RS suggestion will be replaced by the Merino suggestion in the common case, assuming RS is faster than Merino. That will cause flicker in the UI, and we have too much flicker already.
  2. Modified race to the highest-priority suggestion: When RS finishes, add its suggestion if the Merino suggestion hasn't already been added and only after some small timeout has elapsed. When Merino finishes, add its suggestion unconditionally. This might improve the flicker problem of option 1, but it might not, depending on timing.
  3. Hard timeout for Merino: Cancel the Merino fetch after some timeout. Don't add either suggestion before the timeout elapses.

We decided we'll do option 3.

No reason not to add a Nimbus variable for the timeout value.

FWIW none of the other front-end fetch callers seem to use timeouts at all -- not a good excuse we shouldn't ofc.

This adds a 200ms timeout using setTimeout and the current AbortController.
The timeout value can be set in prefs and Nimbus.

Blocks: 1737651
Blocks: 1737923
Pushed by dwillcoxon@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9ff0042f482d
Add a timeout mechanism for quick suggest fetches from Merino. r=nanj
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
Flags: qe-verify-
Flags: in-testsuite+
Iteration: 95.2 - Oct 18 - Oct 31 → 96.1 - Nov 1 - Nov 14

Comment on attachment 9248171 [details]
Bug 1737928 - Add a timeout mechanism for quick suggest fetches from Merino.

Beta/Release Uplift Approval Request

  • User impact if declined: We need this for the Firefox Suggest preferences redesign targeting 95/94.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: Please see uplift spreadsheet: https://docs.google.com/spreadsheets/d/1LavihS-VOPFYEyum7mrx6FKXmuQeHi9xQHfGNSxjnoY/edit?usp=sharing
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This only affects Firefox Suggest suggestions returned from the Merino server. Currently such suggestions are disabled for all users and will only be enabled initially in a future Nimbus rollout.
  • String changes made/needed:
Attachment #9248171 - Flags: approval-mozilla-beta?

Comment on attachment 9248171 [details]
Bug 1737928 - Add a timeout mechanism for quick suggest fetches from Merino.

Approved for 95.0b5.

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

[Tracking Requested - why for this release]: We need this for the Firefox Suggest preferences redesign targeting 95/94.

Comment on attachment 9248171 [details]
Bug 1737928 - Add a timeout mechanism for quick suggest fetches from Merino.

Beta/Release Uplift Approval Request

  • User impact if declined: We need this for the Firefox Suggest preferences redesign targeting 95/94.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: Please see uplift spreadsheet: https://docs.google.com/spreadsheets/d/1LavihS-VOPFYEyum7mrx6FKXmuQeHi9xQHfGNSxjnoY/edit?usp=sharing
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This only affects Firefox Suggest suggestions returned from the Merino server. Currently such suggestions are disabled for all users and will only be enabled initially in a future Nimbus rollout.
  • String changes made/needed:
Attachment #9248171 - Flags: approval-mozilla-release?

Comment on attachment 9248171 [details]
Bug 1737928 - Add a timeout mechanism for quick suggest fetches from Merino.

Approved for 94.0.2.

Attachment #9248171 - Flags: approval-mozilla-release? → approval-mozilla-release+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: