Skip to content

fix convex-test Date returns#291

Merged
zbeyens merged 4 commits into
mainfrom
codex/96-t-run-date-serialization
Jun 15, 2026
Merged

fix convex-test Date returns#291
zbeyens merged 4 commits into
mainfrom
codex/96-t-run-date-serialization

Conversation

@zbeyens

@zbeyens zbeyens commented Jun 15, 2026

Copy link
Copy Markdown
Member

🐛 Fixes #96

🟢 95-100% confidence

Phase 🧪 Tests 🌐 Browser
Reproduced 🔴 bun run vitest run convex/orm/mutations.test.ts -t "should allow returning hydrated Date values from t.run in convex-test" failed with Convex rejecting .createdAt as a native Date. ➖ N/A
Verified 🟢 bun run vitest run convex/orm/mutations.test.ts; 🟢 bun typecheck; 🟢 bun lint:fix; 🟢 bun check; 🟢 autoreview P2 fixed, P3 rejected by repo staging policy. ➖ N/A

✅ Outcome

Returning ORM-hydrated timestamp fields from convexTest().run() no longer crashes the test helper. Dates are converted to Convex-safe millisecond numbers before convex-test serializes the callback result.

⚠️ Caveat

This PR includes the unrelated .tmp/better-auth-oom-latest scratch app because the repo instruction for PRs says to stage all modified and untracked files, even unrelated ones. That is noisy, but it is deliberate policy compliance.

🏗️ Design

The fix lives at the repo convexTest wrapper boundary, not in production ORM hydration. The walker only recurses through arrays and Convex-simple/plain objects, leaving unsupported class instances untouched so Convex still rejects invalid return values.

🧪 Verified

  • bun run vitest run convex/orm/mutations.test.ts -t "should allow returning hydrated Date values from t.run in convex-test" red before fix, green after fix
  • bun run vitest run convex/orm/mutations.test.ts -t "hydrated Date values|unsupported class returns|nullable timestamp columns"
  • bun run vitest run convex/orm/mutations.test.ts
  • bun typecheck
  • bun lint:fix
  • .agents/skills/autoreview/scripts/autoreview --mode local --parallel-tests "bun run vitest run convex/orm/mutations.test.ts"
  • bun check

@changeset-bot

changeset-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 296ad01

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
better-convex Ready Ready Preview, Comment Jun 15, 2026 5:23pm

Request Review

@zbeyens zbeyens merged commit 48f5f5c into main Jun 15, 2026
4 of 5 checks passed
@zbeyens zbeyens deleted the codex/96-t-run-date-serialization branch June 15, 2026 17:24
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.

ORM-hydrated Date objects crash t.run() return serialization in convex-test

1 participant