fix(card): coerce printing Decimal prices inside cache boundary#65
Conversation
getPrintingsForCard is `'use cache'`, which serializes its return value. Prisma Decimal price columns can't cross that boundary, so the card page threw "Decimal objects are not supported" before the page/route-level serializePrintings ever ran (errors surfaced with the `Cache` prefix). The fix: - Coerce Decimal->number via serializePrintings *inside* getPrintingsForCard, so the cache only ever stores plain ClientPrinting objects - Rebase ClientPrinting/serializePrinting on the Prisma Printing model type instead of the query ReturnType, breaking the now-circular import - Drop the redundant serializePrintings wrap in the card page and printings API route - Update the query test to assert Decimal->number coercion
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR consolidates printing data serialization from the API route and page component into the query layer. ChangesPrinting Serialization Consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
app/(ui)/card/[slug]/page.tsxParsing error: The keyword 'import' is reserved app/api/cards/[id]/printings/route.tsParsing error: The keyword 'import' is reserved lib/card/__tests__/printing-queries.test.tsParsing error: The keyword 'import' is reserved
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. Comment |
getPrintingsForCard is
'use cache', which serializes its return value. Prisma Decimal price columns can't cross that boundary, so the card page threw "Decimal objects are not supported" before the page/route-level serializePrintings ever ran (errors surfaced with theCacheprefix).The fix:
Description
Fixes: #
Checklist
pnpm test) and lint is cleanrevalidate/dynamic/unstable_cache— used'use cache'+cacheLife/cacheTag<Link>imported fromapp/_components/link.tsx, notnext/linkScreenshots / notes
Summary by CodeRabbit