Skip to content

Conversation

@RhysSullivan
Copy link
Contributor

@RhysSullivan RhysSullivan commented Dec 15, 2025

Causes a runtime crash without this


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Summary by CodeRabbit

  • Bug Fixes
    • Improved query memoization to properly detect changes in query parameters, ensuring queries re-run when needed and avoid unnecessary re-executions when parameters are structurally equivalent.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Walkthrough

The memoization dependency array in makeUseQueryWithStatus now converts query arguments to their convex-structured JSON form before stringification, changing when cached values are invalidated based on the transformed argument representation.

Changes

Cohort / File(s) Summary
Query memoization dependency optimization
packages/convex-helpers/react.ts
Modified useMemo dependency array in makeUseQueryWithStatus to use JSON.stringify(convexToJson(args)) instead of JSON.stringify(args), altering when memoized values are recomputed based on convex-converted argument representation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Key area for attention: Verify that convexToJson produces consistent, deterministic output for equivalent arguments to ensure memoization behaves as intended and doesn't cause unexpected cache invalidations or stale computations.
  • Consideration: Confirm that this change aligns with how query arguments are actually structured and compared in the Convex system to avoid subtle behavioral differences in memoization timing.

Poem

🐰 A hop, skip, and stringify away—
Where convex JSON saves the day!
Memoization, now refined and neat,
Dependencies aligned, the logic's sweet! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: applying convexToJSON to args before JSON.stringify, which matches the code modification and fixes a runtime crash.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f43db36 and 7aeb1b4.

📒 Files selected for processing (1)
  • packages/convex-helpers/react.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

When modifying complex TypeScript types, run npm run typecheck in the repository root to ensure types are correct, rather than running tsc manually

Files:

  • packages/convex-helpers/react.ts
🔇 Additional comments (1)
packages/convex-helpers/react.ts (1)

132-143: Using convexToJson in the memo deps is correct and matches existing patterns

Switching the dependency key from JSON.stringify(args) to JSON.stringify(convexToJson(args)) is the right fix to avoid runtime crashes when args contain non‑JSON‑native Convex values, and it aligns useQuery’s behavior with the usePaginatedQuery logic below that already does the same. The actual query still receives the original args, so runtime semantics are unchanged apart from safer/stabler memoization keys.

No further changes needed here.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 15, 2025

Open in StackBlitz

npm i https://pkg.pr.new/get-convex/convex-helpers@879

commit: 7aeb1b4

Copy link
Collaborator

@ianmacartney ianmacartney left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@Nicolapps Nicolapps left a comment

Choose a reason for hiding this comment

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

Thank you!

@Nicolapps Nicolapps merged commit 517edcf into get-convex:main Dec 15, 2025
5 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.

3 participants