Skip to content

Commit 08ed61f

Browse files
committed
Gate compute span to non-loading render pass
Hoist isRecentSearchesDataLoaded above the compute span guard so ComputeOptions only starts once all loading states have cleared, preventing idle Onyx hydration time from inflating the span on cold opens. Made-with: Cursor
1 parent 4016f14 commit 08ed61f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/Search/SearchAutocompleteList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ function SearchAutocompleteList({
166166

167167
const computeSpanStarted = useRef(false);
168168
const spanHandoffDone = useRef(false);
169+
const isRecentSearchesDataLoaded = !isLoadingOnyxValue(recentSearchesMetadata);
169170
// eslint-disable-next-line react-hooks/refs -- intentional: telemetry span must start during render to measure computation time
170-
if (!computeSpanStarted.current && areOptionsInitialized && getSpan(CONST.TELEMETRY.SPAN_OPEN_SEARCH_ROUTER)) {
171+
if (!computeSpanStarted.current && areOptionsInitialized && isRecentSearchesDataLoaded && getSpan(CONST.TELEMETRY.SPAN_OPEN_SEARCH_ROUTER)) {
171172
startSpan(CONST.TELEMETRY.SPAN_SEARCH_ROUTER_COMPUTE_OPTIONS, {
172173
name: CONST.TELEMETRY.SPAN_SEARCH_ROUTER_COMPUTE_OPTIONS,
173174
op: 'function',
@@ -446,7 +447,6 @@ function SearchAutocompleteList({
446447
}
447448
}, [autocompleteQueryValue, onHighlightFirstItem, normalizedReferenceText]);
448449

449-
const isRecentSearchesDataLoaded = !isLoadingOnyxValue(recentSearchesMetadata);
450450
const isLoading = !isRecentSearchesDataLoaded || !areOptionsInitialized;
451451

452452
if (isLoading) {

0 commit comments

Comments
 (0)