From e0630b865303fbbb51f8c89f6a47f13ba2cb0bf7 Mon Sep 17 00:00:00 2001 From: Weiko Date: Tue, 31 Mar 2026 12:02:50 +0200 Subject: [PATCH] Fix TransactionNotStartedError (#19155) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Context Checked in the codebase where we are trying to rollback a non-active transaction. packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts seemed to be the only place where it happens. We could enforce this with a lint rule in the future 🤔 --- .../core-modules/auth/services/sign-in-up.service.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts index 5511ae3175..5d33841516 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts @@ -9,7 +9,6 @@ import { Repository, type DataSource, type QueryRunner } from 'typeorm'; import { v4 } from 'uuid'; import { USER_SIGNUP_EVENT_NAME } from 'src/engine/api/graphql/workspace-query-runner/constants/user-signup-event-name.constants'; -import { MAX_WORKSPACES_WITHOUT_ENTERPRISE_KEY } from 'src/engine/core-modules/auth/constants/max-workspaces-without-enterprise-key.constants'; import { type AppTokenEntity } from 'src/engine/core-modules/app-token/app-token.entity'; import { ApplicationService } from 'src/engine/core-modules/application/application.service'; import { @@ -21,6 +20,7 @@ import { compareHash, hashPassword, } from 'src/engine/core-modules/auth/auth.util'; +import { MAX_WORKSPACES_WITHOUT_ENTERPRISE_KEY } from 'src/engine/core-modules/auth/constants/max-workspaces-without-enterprise-key.constants'; import { type AuthProviderWithPasswordType, type ExistingUserOrPartialUserWithPicture, @@ -593,16 +593,18 @@ export class SignInUpService { ); await queryRunner.commitTransaction(); - await this.workspaceCacheService.invalidateAndRecompute(workspaceId, [ - 'flatApplicationMaps', - ]); return { user, workspace }; } catch (error) { - await queryRunner.rollbackTransaction(); + if (queryRunner.isTransactionActive) { + await queryRunner.rollbackTransaction(); + } throw error; } finally { await queryRunner.release(); + await this.workspaceCacheService.invalidateAndRecompute(workspaceId, [ + 'flatApplicationMaps', + ]); } }