Skip to content

fix: handle invalid date objects in jsonify stringify#2851

Merged
bartlomieju merged 2 commits intodenoland:mainfrom
dahlia:main
Mar 26, 2026
Merged

fix: handle invalid date objects in jsonify stringify#2851
bartlomieju merged 2 commits intodenoland:mainfrom
dahlia:main

Conversation

@dahlia
Copy link
Copy Markdown
Contributor

@dahlia dahlia commented Apr 14, 2025

Summary

  • Handles the case when Date.toISOString() throws for invalid dates by catching the error and serializing as "Invalid Date"
  • Round-trips correctly: new Date("Invalid Date") serializes to ["Date","Invalid Date"] and deserializes back to an invalid Date object
  • Adds test case and snapshot for invalid Date

Test plan

  • deno test -A packages/fresh/src/jsonify/ — all 39 tests pass

🤖 Generated with Claude Code

@dahlia
Copy link
Copy Markdown
Contributor Author

dahlia commented Apr 14, 2025

The tests failed, but apparently it's not related to the changes I made.

# Conflicts:
#	packages/fresh/src/jsonify/stringify.ts
@bartlomieju bartlomieju changed the title Fix: Add support for invalid Date objects in jsonify stringify fix: handle invalid date objects in jsonify stringify Mar 26, 2026
@bartlomieju bartlomieju enabled auto-merge (squash) March 26, 2026 08:27
@bartlomieju bartlomieju merged commit b11d1d9 into denoland:main Mar 26, 2026
6 checks passed
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.

2 participants