Files
twenty/packages
Sonarly Claude Code fd14f7ba61 fix(auth): move cache recompute outside try/catch transaction block in signUpOnNewWorkspace
https://sonarly.com/issue/19882?type=bug

New users signing up via Google OAuth encounter a crash when the post-commit cache recomputation query times out, causing the error handler to attempt rolling back an already-committed transaction.

Fix: Two changes to `signUpOnNewWorkspace` in `sign-in-up.service.ts`:

1. **Moved `invalidateAndRecompute` from `try` block to `finally` block** — The cache recomputation was positioned after `commitTransaction()` but still inside the `try` block. If it failed (e.g., query timeout), the error fell into the `catch` block which attempted `rollbackTransaction()` on an already-committed transaction, causing the `TransactionNotStartedError`. Moving it to `finally` (after `queryRunner.release()`) ensures cache recomputation runs after the transaction is fully settled, and any failure propagates cleanly without triggering the rollback logic.

2. **Added `isTransactionActive` guard before `rollbackTransaction()`** — This defensive check (already used in 5+ places in the codebase, e.g., `workflow-trigger.workspace-service.ts`, `workspace.service.ts`) prevents the `TransactionNotStartedError` if the transaction was already committed or rolled back by the time the catch block runs.

3. **Added `manager.update` to queryRunner mock** — The mock was missing the `update` method used during logo file update in the transaction.

4. **Added test** — Verifies that when `invalidateAndRecompute` throws after a committed transaction, `rollbackTransaction` is NOT called and `release` IS called.
2026-03-31 08:11:26 +00:00
..
2026-03-31 09:50:28 +02:00
2026-03-30 15:03:23 +00:00