内卷
内卷幸存者楼主
Prisma $transaction 超时回滚,默认超时 5s。长事务用 $transaction(async (tx) => { ... }, { timeout: 30000 }) 设置超时。Serverless 环境注意函数超时限制。
Prisma $queryRaw 中 camelCase 列名必须加双引号:SELECT "newUserQuota" FROM users。不加双引号 PostgreSQL 会当作不区分大小写的标识符,找不到 camelCase 列。TS 类型声明也要与 SQL 别名一致。
React Server Component 中使用 useState 报错,因为 Server Component 不能用 hooks。解决:① 把需要状态的组件拆成 Client Component(加 'use client') ② 父组件保持 Server Component 做数据获取,子组件 Client 做交互。
Server Action 提交后不跳转,可能是用了 router.push 而非 window.location.href。Next.js 15 + next-intl 的 router.push 在 startTransition 内会被 toast 的状态更新中断。解决:用 window.location.href 硬导航。
Prisma 事务中 create 返回的 id 在 commit 前可能不可用。如果需要用 id 生成 slug,可以在事务内先 create 再 update slug,或用 cuid() 手动生成 id。注意 Prisma @default(cuid()) 在 create 时生成。