Checking the time budget before each fetchAll batch, with room left for one slow batch, is a careful piece of design. One case it doesn't cover: a SKU that the endpoint answers with a 404, or without an available field, is never cached. It shows 'Not fetched yet' forever, which reads as 'wait a bit'. Every recalculation spends a request on it again, which eats into the 20-second budget meant for the SKUs that can succeed. For 404s specifically (not 5xx), you could cache a short-lived 'not found' marker, say for an hour, and return 'Unknown SKU' instead. That stops the repeat requests and tells the user something they can act on.
Hayrullah Kar
Checking the time budget before each
fetchAllbatch, with room left for one slow batch, is a careful piece of design. One case it doesn't cover: a SKU that the endpoint answers with a 404, or without anavailablefield, is never cached. It shows 'Not fetched yet' forever, which reads as 'wait a bit'. Every recalculation spends a request on it again, which eats into the 20-second budget meant for the SKUs that can succeed. For 404s specifically (not 5xx), you could cache a short-lived 'not found' marker, say for an hour, and return 'Unknown SKU' instead. That stops the repeat requests and tells the user something they can act on.