Skip to content

fix(compare): retry replacement suggestions after transient fetch failures#2469

Open
trivikr wants to merge 1 commit intonpmx-dev:mainfrom
trivikr:fix/replacements-fetch-error
Open

fix(compare): retry replacement suggestions after transient fetch failures#2469
trivikr wants to merge 1 commit intonpmx-dev:mainfrom
trivikr:fix/replacements-fetch-error

Conversation

@trivikr
Copy link
Copy Markdown
Contributor

@trivikr trivikr commented Apr 11, 2026

🔗 Linked issue

N/A

🧭 Context

The compare page caches replacement lookups per package in useCompareReplacements. That cache treated transient fetch failures the same as a real “no replacement” response by storing null for both cases. Once that happened, the package was considered already checked and would never be fetched again for the rest of the session.

In practice, a temporary API failure, offline blip, or server 500 could permanently suppress replacement suggestions until the app was reloaded.

📚 Description

This PR changes compare-page replacement caching so only successful fetch results are persisted.

Successful null responses are still cached, which preserves the existing optimization for packages that truly have no replacement suggestion. Thrown fetch errors are no longer written into the cache, which allows the package to be retried on a later watch cycle instead of being suppressed for the rest of the session.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 11, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 11, 2026 1:43am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 11, 2026 1:43am
npmx-lunaria Ignored Ignored Apr 11, 2026 1:43am

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

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
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1129de60-15e4-4d63-9615-5f3061ded411

📥 Commits

Reviewing files that changed from the base of the PR and between 0164064 and 66cde5b.

📒 Files selected for processing (2)
  • app/composables/useCompareReplacements.ts
  • test/nuxt/composables/use-compare-replacements.spec.ts

📝 Walkthrough

Walkthrough

Modified the useCompareReplacements composable to refine failure handling in the fetchReplacements function. Failed fetch attempts now return objects marked with failed: true rather than null replacement entries, and the map-update loop skips these marked entries. Test coverage was expanded to include scenarios for transient fetch failures triggering retries and successful null replacements being cached. The test helper was updated to accept properly typed parameters.

Suggested reviewers

  • ghostdevv
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly explains the bug, context, and proposed solution related to caching replacement lookups.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

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.

1 participant