From 051b5fc220edfcafbeed422b289311f74c2b94a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lucas=20de=20Oliveira=20Lopes?= <55464917+jlucaso1@users.noreply.github.com> Date: Wed, 8 Oct 2025 16:14:58 -0300 Subject: [PATCH] perf(addTransactionCapability): streamline transaction handling and improve concurrency control (#1887) --- src/Utils/auth-utils.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Utils/auth-utils.ts b/src/Utils/auth-utils.ts index d87e8a4e..e20144ca 100644 --- a/src/Utils/auth-utils.ts +++ b/src/Utils/auth-utils.ts @@ -116,7 +116,6 @@ export const addTransactionCapability = ( logger: ILogger, { maxCommitRetries, delayBetweenTriesMs }: TransactionCapabilityOptions ): SignalKeyStoreWithTransaction => { - // AsyncLocalStorage for transaction context const txStorage = new AsyncLocalStorage() // Queues for concurrency control @@ -189,9 +188,8 @@ export const addTransactionCapability = ( const ctx = txStorage.getStore() if (!ctx) { - // No transaction - direct read with mutex protection (not queue) - // Use mutex instead of queue to provide mutual exclusion for reads and writes, reducing queuing overhead and improving event loop responsiveness (does not allow concurrent reads) - return getTxMutex(type).runExclusive(() => state.get(type, ids)) + // No transaction - direct read without exclusive lock for concurrency + return state.get(type, ids) } // In transaction - check cache first