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: Shallow equality check on cache parsing input #580

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

franky47
Copy link
Member

@franky47 franky47 commented Jun 26, 2024

A change introduced in Next.js 15.0.0-canary.41 (precisely vercel/next.js#67105) broke the referential stability that the cache.parse method was expecting to detect parse being called with the same search params.

Now we're using a shallow equality check, as the values seem to still be referentially stable.

Copy link

vercel bot commented Jun 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuqs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2024 9:41pm

A change introduced in Next.js 15.0.0-canary.41 (precisely vercel/next.js#67105)
broke the referential stability that the cache.parse method was expecting to detect
`parse` being called with the same search params.

Now we're using a deep equality check by caching the serialized query string
that was parsed, and comparing it with the input when called again.
While the searchParams object is not referentially stable,
its values are, so we can do a simple shallow comparison.
Adding a test case in the e2e test to make sure this holds
with array of values (repeated keys in the query string).
@franky47 franky47 changed the title fix: Deep equality check on cache parsing input fix: Shallow equality check on cache parsing input Jun 26, 2024
@franky47 franky47 merged commit 4d4fc9e into next Jun 26, 2024
15 checks passed
@franky47 franky47 deleted the fix/search-params-deep-equals branch June 26, 2024 21:49
Copy link

🎉 This PR is included in version 1.17.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant