海角
海角天涯楼主
Prisma $transaction 超时回滚,默认超时 5s。长事务用 $transaction(async (tx) => { ... }, { timeout: 30000 }) 设置超时。Serverless 环境注意函数超时限制。
Server Action 提交后不跳转,可能是用了 router.push 而非 window.location.href。Next.js 15 + next-intl 的 router.push 在 startTransition 内会被 toast 的状态更新中断。解决:用 window.location.href 硬导航。
Prisma 索引没生效查询慢,确认:① 查询条件字段是否建了 @@index ② 迁移是否执行 ③ 用 EXPLAIN ANALYZE 查看执行计划 ④ 是否有函数索引需求 ⑤ 大表考虑分区。
Next.js 路由组 layout 中调用 auth() 报错,因为 layout 是所有子页面的公共外壳,async layout 会拖慢导航。解决:layout 保持同步,用客户端组件 + useSession() 读取 session 缓存。