Skip to content

The open alternative to Salesforce, designed for AI.

Fix TransactionNotStartedError (#19155)

Weikoe0630b865303
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 5511ae3175d..5d338415169 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',
+ ]);
}
}