tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ebe4d7c6de3bf6f9d5b2da154f89439e8d52c055
parent 77c24e7f8a88e3dc41fa60e9e494ccd553eeabda
Author: Drew Willcoxon <adw@mozilla.com>
Date:   Tue, 14 Oct 2025 02:37:56 +0000

Bug 1994066 - Make MerinoClient log round-trip times/fetch durations. r=daisuke

Differential Revision: https://phabricator.services.mozilla.com/D268455

Diffstat:
Mbrowser/components/urlbar/MerinoClient.sys.mjs | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/browser/components/urlbar/MerinoClient.sys.mjs b/browser/components/urlbar/MerinoClient.sys.mjs @@ -332,9 +332,11 @@ export class MerinoClient { // `response` in the outer scope and set it here instead of returning // the response from this inner function and assuming it will also be // returned by `Promise.race`. - response = await this.#fetch(url, { signal: controller.signal }); + let result = await this.#fetch(url, { signal: controller.signal }); + response = result?.response; this.#lazy.logger.debug("Got response", { status: response?.status, + elapsedMs: result ? result.elapsedMs : "n/a", ...details, }); if (!response?.ok) { @@ -474,8 +476,14 @@ export class MerinoClient { * Options object. * @param {AbortSignal} options.signal * An `AbortController.signal` for the fetch. - * @returns {Promise<?OHTTPResponse|?Response>} - * The fetch `Response` or null if a response can't be fetched. + * @returns {Promise<?FetchResult>} + * The fetch result, or null if the fetch couldn't be started. + * + * @typedef {object} FetchResult + * @property {OHTTPResponse|Response} response + * The response object. + * @property {number} elapsedMs + * The duration of the fetch in ms. */ async #fetch(url, { signal }) { let configUrl; @@ -514,7 +522,7 @@ export class MerinoClient { elapsedMs, ]); - return response; + return { response, elapsedMs }; } static _test_disableCache = false;