Skip to content

Conversation

@janglad
Copy link
Contributor

@janglad janglad commented Nov 2, 2025

Previously

const serialize = createSerializer({
	arr: parseAsArrayOf(parseAsString).withDefault([])
 })

would throw when serialising with { arr : null } .

TypeError: Cannot read properties of null (reading 'length')
 ❯ eq src/parsers.ts:504:13
    502|         return true // Referentially stable
    503|       }
    504|       if (a.length !== b.length) {
       |             ^
    505|         return false
    506|       }

From what I understand this should be allowed, and is indicated as such in the types. This was caused by the equality fn being called with null. This PR fixes this and adds a test to cover this case.

@vercel
Copy link

vercel bot commented Nov 2, 2025

@janglad is attempting to deploy a commit to the 47ng Team on Vercel.

A member of the Team first needs to authorize it.

@janglad janglad changed the title Fix TypeError in serializer for array with default value fix: TypeError in serializer for array with default value Nov 2, 2025
@franky47 franky47 changed the title fix: TypeError in serializer for array with default value fix: TypeError in serializer for array with default value Nov 3, 2025
@franky47 franky47 added this to the 🪵 Backlog milestone Nov 3, 2025
Copy link
Member

@franky47 franky47 left a comment

Choose a reason for hiding this comment

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

Ah, good catch, thanks! Yes it should definitely allow null values on properties to remove them.

@vercel
Copy link

vercel bot commented Nov 3, 2025

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

Project Deployment Preview Comments Updated (UTC)
nuqs Ready Ready Preview Comment Nov 4, 2025 0:04am

@franky47 franky47 added the deploy:preview Deploy a preview version of this PR on pkg.pr.new label Nov 3, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 3, 2025

pnpm add https://pkg.pr.new/nuqs@1197

commit: bec3404

@franky47 franky47 enabled auto-merge (squash) November 4, 2025 00:04
@franky47 franky47 merged commit d072a85 into 47ng:next Nov 4, 2025
27 checks passed
@franky47
Copy link
Member

franky47 commented Nov 4, 2025

I need to work on the CI part of things to follow NPM's new security directives (OIDC trusted publishing), as they will deprecate long-lived deployment tokens soon, then this should be good to go live.

Feel free to use the pkg.pr.new deployment if you want to use the hotfix in the mean time:

pnpm add https://pkg.pr.new/nuqs@bec3404

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🎉 This PR is included in version 2.7.3-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🎉 This PR is included in version 2.7.3 🎉

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

deploy:preview Deploy a preview version of this PR on pkg.pr.new feature/serializer released on @beta released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants