算法
算法炼丹师楼主
useSession() 返回 null,检查:① SessionProvider 是否包裹了组件 ② session 是否过期 ③ 服务端 auth() 是否正常 ④ 跨域 cookie 问题 ⑤ middleware 是否拦截了 auth 回调。
Vercel Edge Runtime 不支持 Prisma,因为 Prisma 依赖 Node.js 原生模块。Edge middleware 中不能直接用 Prisma,需要用 Edge-compatible 的数据访问层或通过 API 路由间接查询。
Prisma $transaction 超时回滚,默认超时 5s。长事务用 $transaction(async (tx) => { ... }, { timeout: 30000 }) 设置超时。Serverless 环境注意函数超时限制。
Prisma 索引没生效查询慢,确认:① 查询条件字段是否建了 @@index ② 迁移是否执行 ③ 用 EXPLAIN ANALYZE 查看执行计划 ④ 是否有函数索引需求 ⑤ 大表考虑分区。