Skip to content

fix: preserve search results during preference hydration - #3109

Open
anilloutombam wants to merge 2 commits into
npmx-dev:mainfrom
anilloutombam:fix/search-page-size-results
Open

fix: preserve search results during preference hydration#3109
anilloutombam wants to merge 2 commits into
npmx-dev:mainfrom
anilloutombam:fix/search-page-size-results

Conversation

@anilloutombam

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Fixes #2617

🧭 Context

When the page size was set to 50 or more, the first search could show no package results. Reloading the same search page made the results appear.

This happened because the saved page-size preference was loaded while the initial search was still running.

📚 Description

I changed fetchMore to wait for the initial search to finish before using its results. This prevents an empty response from being cached while the saved preference is loading.

I also added a regression test that reproduces this timing issue and checks that the package results are preserved.

@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview Aug 1, 2026 7:40am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Aug 1, 2026 7:40am
npmx-lunaria Ignored Ignored Aug 1, 2026 7:40am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1994f346-09a1-4917-9779-e99bbc8574f4

📥 Commits

Reviewing files that changed from the base of the PR and between d1dafd1 and 245fc7d.

📒 Files selected for processing (1)
  • app/composables/npm/useSearch.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/composables/npm/useSearch.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved search result loading so additional results wait for the initial search to complete, preventing incomplete or inconsistent results when loading more items.
  • Tests

    • Added coverage for search suggestions and loading additional results after changing the requested page size.

Walkthrough

fetchMore now waits for a pending initial search to finish. Tests cover deferred search resolution, page-size changes, and final result data.

Changes

npm search completion

Layer / File(s) Summary
Synchronise additional result loading
app/composables/npm/useSearch.ts, test/nuxt/composables/use-search.spec.ts
fetchMore awaits asyncData.refresh() before loading further results. Tests cover deferred initial search resolution and updated page sizes.

Possibly related PRs

Suggested reviewers: ghostdevv

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes preserving search results during preference hydration and matches the primary change.
Description check ✅ Passed The description explains the page-size timing issue, the fix, and the regression test, all of which match the changeset.
Linked Issues check ✅ Passed The implementation and regression test address issue #2617 by waiting for the initial search before loading additional results.
Out of Scope Changes check ✅ Passed All changes are limited to the search composable and its regression tests, which directly support issue #2617.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/composables/npm/useSearch.ts`:
- Around line 231-233: Update the pending-request branch in fetchMore within
app/composables/npm/useSearch.ts (lines 231-233) to call asyncData.refresh with
dedupe set to defer, ensuring it awaits the existing request rather than
replacing it. Add or update coverage in test/nuxt/composables/use-search.spec.ts
(lines 60-87) to verify fetchMore joins the in-flight request.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b5f5af6-f155-407e-8bd7-caf86263cdc4

📥 Commits

Reviewing files that changed from the base of the PR and between e951b5f and d1dafd1.

📒 Files selected for processing (2)
  • app/composables/npm/useSearch.ts
  • test/nuxt/composables/use-search.spec.ts

Comment thread app/composables/npm/useSearch.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initial search reports no package results if pageSize is >=50

1 participant