Skip to content

Fix serialization for Invalid/NaN dates#152

Merged
kentonv merged 2 commits into
cloudflare:mainfrom
VastBlast:fix-150-2
May 7, 2026
Merged

Fix serialization for Invalid/NaN dates#152
kentonv merged 2 commits into
cloudflare:mainfrom
VastBlast:fix-150-2

Conversation

@VastBlast

@VastBlast VastBlast commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #150 to correctly serialize/deserialize invalid/NaN dates

@changeset-bot

changeset-bot Bot commented Mar 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: efb4602

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
capnweb Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kentonv

kentonv commented Apr 16, 2026

Copy link
Copy Markdown
Member

Sorry for the very slow review, I've been deep underwater on my inbox for the past month. :(

This seems like a good idea, but I suppose Infinity and -Infinity have the same problem, and we can't encode all of them as null. Perhaps we should encode them as "inf", "-inf", and "nan", like we do for the raw numbers?

@kentonv

kentonv commented May 7, 2026

Copy link
Copy Markdown
Member

OK I tried to test this and discovered that new Date(Infinity).getTime() actually returns NaN... infinities are not supported by Date. Weird!

@kentonv

kentonv commented May 7, 2026

Copy link
Copy Markdown
Member

that's... not the best randomly-generated changeset name but oh well it's a temporary file...

@pkg-pr-new

pkg-pr-new Bot commented May 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/capnweb@152

commit: efb4602

@kentonv kentonv merged commit 9e499e2 into cloudflare:main May 7, 2026
5 checks passed
@github-actions github-actions Bot mentioned this pull request May 7, 2026
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.

RPC serialization fails for Invalid/NaN Date

2 participants