采购提交与报销新建/提交事务显式使用10秒上限 [09-27-purchase-submit-tx-timeout]

负载下采购提交事务超过 Prisma 交互事务默认 5000ms(P2028)返回 500。
分段计时显示无单一瓶颈(总时长中位 843ms、最大 3506ms,编号锁等待
最多 535ms),是约 20 条顺序查询整体变慢贴近上限。报销新建/提交同结构。
三处改用项目既有的 { maxWait: 5000, timeout: 10000 },事务内容不变;
新增采购与报销提交的事务选项回归断言。

Co-Authored-By: Claude Opus 5.5 <[email protected]>
这个提交包含在:
2026-09-27 12:27:04 +08:00
共同撰写人 Claude Opus 5.5
父节点 a6ff2dc3b1
当前提交 b6f0c83608
共修改 9 个文件,包含 92 行新增和 4 行删除
@@ -325,7 +325,7 @@ describe("reimbursements routes expense standard integration", () => {
it.each([true, false])("avoids unused bound-invoice counts: per-item guard=%s", async invoiceGuardEnabled => {
resolveEntityPrecheckMock.mockResolvedValue(buildPrecheck());
const { app, tx } = await buildApp({ invoiceGuardEnabled, reimbursementItems: [{
const { app, prisma, tx } = await buildApp({ invoiceGuardEnabled, reimbursementItems: [{
id: "item-no-invoice", amount: "180.00",
expense_type: { code: "office", category: "office", requires_invoice: invoiceGuardEnabled },
}] });
@@ -336,6 +336,8 @@ describe("reimbursements routes expense standard integration", () => {
expect(tx.reimbursementItem.findFirst).not.toHaveBeenCalled();
expect(tx.reimbursementItem.aggregate).toHaveBeenCalledTimes(1);
expect(tx.workflowHistory.create).toHaveBeenCalled();
// Prisma's 5s interactive-transaction default was exceeded under load (P2028 -> 500).
expect(prisma.$transaction).toHaveBeenCalledWith(expect.any(Function), { maxWait: 5000, timeout: 10000 });
} finally { await app.close(); }
});