You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][bug] connect→disconnect race leaks a connection in activeConnections map (test documents as expected) #280
connectionStore.ts's connect() and disconnect() actions both call api.* independently with no cancellation hook.
Problem
Click Connect on a slow profile, then immediately Cancel/Disconnect — the in-flight connect() resolves later and pushes the connection into activeConnections while the earlier disconnect() had nothing to remove. End state: live MySQL pool with no client-side reference, no way to close from UI without app restart. connectionStore.test.ts:393-400 explicitly documents and ships the leaky behavior as the contract.
Files
src/stores/connectionStore.ts:58-72, 74-90
src/stores/tests/connectionStore.test.ts:374-411
Repro
Open Connect on a profile that takes >500ms (latency simulation). Within 200ms click Cancel. After both settle, activeConnections has an entry for a connection the UI no longer references.
Expected
Race resolves cleanly: either the connect is cancelled before applying, or the connection is auto-disconnected after resolution when its cancel flag is set.
Proposed fix
Scope S. Track Map<profileId, AbortController> (or Set<pendingProfileIds>) in store; on disconnect(profileId) during in-flight connect, set a skip flag; on connect resolution, check flag and immediately api.disconnect. Flip the race test to assert no leak.
Acceptance
Existing race test flips from leaky to clean. Manual repro shows no activeConnections entry after connect+cancel.
Fixed by #527. Disconnect issued before connect resolved found nothing to remove, and the resolving connect then added the entry — leaving a live pool on the server that nothing on this side could close until restart.
Disconnect now records the intent when the id is not yet known, and a connect landing on a cancelled id closes the pool on the server rather than just dropping the reference: the pool is real, so discarding the handle is not enough. Disconnect also stopped calling the backend for an id this side does not have, which used to raise a spurious "not found" for an ordinary cancel.
The existing test asserted the leak as the contract and was rewritten:
// Documenting current behavior: connect wins because disconnect// ran before the connection was added to activeConnections.
Not auto-closed because the PR body wrote Refs #280.
Activity
fix(connection): start without a keyring, and stop cancelled connects…
EVWorth commentedon Sep 7, 2026
Fixed by #527. Disconnect issued before connect resolved found nothing to remove, and the resolving connect then added the entry — leaving a live pool on the server that nothing on this side could close until restart.
Disconnect now records the intent when the id is not yet known, and a connect landing on a cancelled id closes the pool on the server rather than just dropping the reference: the pool is real, so discarding the handle is not enough. Disconnect also stopped calling the backend for an id this side does not have, which used to raise a spurious "not found" for an ordinary cancel.
The existing test asserted the leak as the contract and was rewritten:
Not auto-closed because the PR body wrote
Refs #280.