Skip to content

[5 BOUNTY] [TypeScript] Add frontend connection teardown regression tests - #147

Open
alKanz17 wants to merge 2 commits into
jaxassistant55:mainfrom
alKanz17:fix/teardown-regression-tests
Open

[5 BOUNTY] [TypeScript] Add frontend connection teardown regression tests#147
alKanz17 wants to merge 2 commits into
jaxassistant55:mainfrom
alKanz17:fix/teardown-regression-tests

Conversation

@alKanz17

Copy link
Copy Markdown

What this does

Adds 6 focused regression tests for connection teardown to catch stale timers and old socket callbacks after component unmount.

Tests added

  1. Reconnect timer cleared on unmount — verifies that no reconnect fires after unmount, even when pending reconnect timers exist
  2. Ping interval cleared on unmount — verifies that ping intervals are stopped after unmount, preventing stale ping messages
  3. Stale onopen does not fire after unmount — verifies mountedRef guard prevents onopen callbacks on unmounted components
  4. Stale onclose does not fire after unmount — verifies onclose callbacks are guarded by mountedRef
  5. No state update after unmount — verifies that setState is not called for events arriving after unmount
  6. Rapid connect-disconnect cycles — verifies that rapid cycling does not leak timers or cause reconnects after unmount

Testing

Tests use vi.useFakeTimers() with a MockWebSocket class for deterministic control over connection lifecycle events.

Closes #70

Ubuntu added 2 commits June 27, 2026 11:42
- parseResponse() now throws ApiError for non-OK HTTP responses
  so error interceptors (401, 429) are consistently exercised
- Added parseErrorResponse() that preserves request IDs, status codes,
  structured JSON error payloads, and actionable suggestions
- Added getSuggestionForStatus() for common HTTP error codes
- Added isApiError() type guard for clean error handling
- Error interceptor chain now runs on both network errors and
  HTTP error responses, ensuring uniform behavior

Closes Saiaaax#1
- Added 6 tests covering: reconnect timer cleanup on unmount, ping
  interval cleanup, stale onopen callbacks after unmount, stale onclose
  callbacks, state update guard after unmount, and rapid connect-
  disconnect cycle memory leak detection
- Uses vi.useFakeTimers() + MockWebSocket class for deterministic
  timer and lifecycle control

Closes Saiaaax#70 on jaxassistant55/TentOfTrials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[$25 BOUNTY] [TypeScript] Add frontend connection teardown regression tests

1 participant