Skip to content

Conversation

trentonallan
Copy link

Fixes #3318

Problem

new Date(undefined) and other invalid dates were being serialized as "0NaN-NaN-NaNTNaN:NaN:NaN.NaN+NaN:NaN" instead of being handled properly.

Solution

Added validation in dateToString and dateToStringUTC functions to check if date is valid before serialization using isNaN(date.getTime()). Invalid dates now throw a TypeError with a clear error message.

Testing

  • Added unit tests to verify invalid dates throw errors
  • Added test to ensure valid dates still work correctly
  • All existing tests pass

@charmander
Copy link
Collaborator

charmander commented Oct 6, 2025

waste of maintainer time with incorrect AI-generated pull request, exhibit n

A correct implementation is already available in #3330.

@charmander charmander closed this Oct 6, 2025
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.

Do not serialize new Date(undefined) as "0NaN-NaN-NaNTNaN:NaN:NaN.NaN+NaN:NaN"

2 participants