fix(auth-utils): improve error message clarity for destroyed state
Addresses Copilot AI comment on PR #79 about misleading error message. Problem: Error message said "Transaction capability destroyed - socket closed" but destroyed flag can be set in contexts other than socket closure, making the message potentially misleading or confusing. Examples when destroyed=true but socket may NOT be closed: 1. Manual cleanup during testing 2. Premature destroy() call due to bug 3. Destroy called but socket still open (edge case) Old message: "Transaction capability destroyed - socket closed" - Assumes socket is closed - Misleading if socket still open - Implies correlation that may not exist New message: "Transaction capability destroyed - cannot initiate new transactions" - States exact condition (destroyed=true) - Explains direct consequence (no new transactions) - No assumption about socket state - More accurate and helpful for debugging Impact: - Improved error clarity for developers debugging issues - No assumption about WHY destroyed is true - Focus on WHAT the error means (can't start transaction) - Better for logs and error tracking This is a low-severity improvement (message clarity only), but addresses valid feedback about potentially confusing error messaging. https://claude.ai/code/session_VMxqX
This commit is contained in:
@@ -320,7 +320,7 @@ export const addTransactionCapability = (
|
||||
// CRITICAL: Check destroyed flag INSIDE mutex to prevent race condition
|
||||
// This ensures atomic check-and-execute: if we acquire mutex, resources exist
|
||||
if (destroyed) {
|
||||
throw new Error('Transaction capability destroyed - socket closed')
|
||||
throw new Error('Transaction capability destroyed - cannot initiate new transactions')
|
||||
}
|
||||
|
||||
const ctx: TransactionContext = {
|
||||
|
||||
Reference in New Issue
Block a user