File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,8 @@ export function useSearch(
261261 const doSearch = provider === 'algolia' ? searchAlgolia : searchNpm
262262 const response = await doSearch ( q , { size, from } )
263263
264+ const beforeCount = cache . value ?. objects . length ?? 0
265+
264266 if ( cache . value && cache . value . query === q && cache . value . provider === provider ) {
265267 const existingNames = new Set ( cache . value . objects . map ( obj => obj . package . name ) )
266268 const newObjects = response . objects . filter ( obj => ! existingNames . has ( obj . package . name ) )
@@ -279,6 +281,12 @@ export function useSearch(
279281 }
280282 }
281283
284+ // Bail if the provider gave us no new unique items
285+ // Without something like this the recursion below never terminates.
286+ if ( ( cache . value ?. objects . length ?? 0 ) === beforeCount ) {
287+ return
288+ }
289+
282290 if (
283291 cache . value &&
284292 cache . value . objects . length < targetSize &&
You can’t perform that action at this time.
0 commit comments