Improved the background request loading order

This commit is contained in:
2026-10-29 17:35:20 -03:00
parent 9b5e751179
commit 00bcfdc42e
6 changed files with 59 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ function createFusionOpportunities({
getOpportunityTypeValues,
readResponseBodyForDebug,
resetDebugRequests = () => {},
loadServiceRequests = async () => {},
environment
}) {
const { fetch } = environment;
@@ -37,7 +38,13 @@ function createFusionOpportunities({
const payload = createOpportunitiesQueryPayload(dateRange, offset, savedSearchNumber);
const requestBody = JSON.stringify(payload);
// One history per query, preserving all pages of the same result set.
if (page === 1) resetDebugRequests();
if (page === 1) {
resetDebugRequests();
// SR queries do not depend on opportunity or product IDs. Keep their
// diagnostics in this query's history and reuse the loaded SR state later.
try { await loadServiceRequests(token, requestVersion); } catch { /* SR failure must not block opportunities. */ }
if (!isCurrentPeriodRequest(requestVersion)) return null;
}
const requestEntry = logRequestStart({
name: "requestOpportunities",
method: "POST",