采购提交与报销新建/提交事务显式使用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]>
这个提交包含在:
@@ -315,6 +315,17 @@ describe("purchase request submit budget precheck gate", () => {
|
||||
|
||||
await app.close();
|
||||
});
|
||||
|
||||
it("runs the submit transaction with a 10s budget instead of Prisma's 5s default", async () => {
|
||||
resolveEntityPrecheckMock.mockResolvedValue(buildPrecheck({ budgetHint: { controlMode: "block" } }));
|
||||
const { app, prisma } = await buildApp({ budgetControlMode: "warn", budgetPrecheckEnabled: false });
|
||||
|
||||
const response = await app.inject({ method: "POST", url: `/api/purchase-requests/${PURCHASE_REQUEST_ID}/submit` });
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(prisma.$transaction).toHaveBeenCalledWith(expect.any(Function), { maxWait: 5000, timeout: 10000 });
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
|
||||
it.each([1, 2])("submits a stored v%s purchase draft under active policy without reclassifying it", async (version) => {
|
||||
|
||||
在新工单中引用
屏蔽一个用户