Skip to content

Commit 219ac17

Browse files
authored
fix: ignore outdated search responses (#788)
1 parent 0b714d1 commit 219ac17

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/composables/useNpmRegistry.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ export function useNpmSearch(
337337

338338
const result = packumentToSearchResult(pkg, downloads?.downloads)
339339

340+
// If query changed/outdated, return empty search response
341+
if (q !== toValue(query)) {
342+
return emptySearchResponse
343+
}
344+
340345
cache.value = {
341346
query: q,
342347
objects: [result],
@@ -357,6 +362,11 @@ export function useNpmSearch(
357362
60,
358363
)
359364

365+
// If query changed/outdated, return empty search response
366+
if (q !== toValue(query)) {
367+
return emptySearchResponse
368+
}
369+
360370
cache.value = {
361371
query: q,
362372
objects: response.objects,

0 commit comments

Comments
 (0)