From 71d59c3312d8d7417ed99bb9c4e6b3c30a93aa89 Mon Sep 17 00:00:00 2001 From: Darien Kindlund Date: Mon, 2 Mar 2026 23:02:46 -0500 Subject: [PATCH] fix: wrap updateRecords with bigTransactionTimeout like createRecords The `updateRecords` method in RecordOpenApiService calls `recordModifyService.updateRecords` directly without wrapping it in a `$tx` block with an explicit timeout. This means it falls back to the Prisma default transaction timeout (5 seconds or PRISMA_TRANSACTION_TIMEOUT env var), rather than using the application's configured `bigTransactionTimeout` (10 minutes by default). In contrast, both `multipleCreateRecords` and `createRecords` already wrap their calls with `{ timeout: this.thresholdConfig.bigTransactionTimeout }`. This inconsistency causes update operations on records with large link fields (e.g., thousands of many-to-many links) to fail with Prisma error P2028 (transaction timeout) even though the operation would complete within the application's intended timeout window. This fix wraps `updateRecords` in `this.prismaService.$tx()` with the same `bigTransactionTimeout` option used by the create methods, ensuring consistent timeout behavior across all record mutation operations. Note: `updateRecord` (singular) delegates to `updateRecords` (plural), so this fix covers both single and batch update operations. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../record/open-api/record-open-api.service.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/nestjs-backend/src/features/record/open-api/record-open-api.service.ts b/apps/nestjs-backend/src/features/record/open-api/record-open-api.service.ts index 1fa9e0d28b..0da6f4c43f 100644 --- a/apps/nestjs-backend/src/features/record/open-api/record-open-api.service.ts +++ b/apps/nestjs-backend/src/features/record/open-api/record-open-api.service.ts @@ -132,10 +132,14 @@ export class RecordOpenApiService { windowId?: string, isAiInternal?: string ) { - const res = await this.recordModifyService.updateRecords( - tableId, - updateRecordsRo as IUpdateRecordsInternalRo, - windowId + const res = await this.prismaService.$tx( + async () => + this.recordModifyService.updateRecords( + tableId, + updateRecordsRo as IUpdateRecordsInternalRo, + windowId + ), + { timeout: this.thresholdConfig.bigTransactionTimeout } ); const appId = this.cls.get('appId');