Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: ensure valid pageParam to prevent negative offset in pagination #371

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

Mohmdev
Copy link

@Mohmdev Mohmdev commented Oct 3, 2024

Fixes #9432

This PR fixes the bug in product pagination by ensuring that pageParam is always valid (i.e., greater than or equal to 1) before calculating the offset. It prevents negative values from being passed to the offset, which was causing a runtime error.

Fix Details:
Instead of just removing -1 from the offset calculation, I used Math.max(1, pageParam) to guarantee that pageParam will always be at least 1. This ensures that the offset calculation is never negative while keeping the existing logic intact.

Copy link

vercel bot commented Oct 3, 2024

@Mohmdev is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

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