mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-06 19:00:14 +00:00
* fix(ios): prevent WebSocket EXC_BAD_ACCESS crash during background teardown (Sentry XHW+YQG, 53K crashes) Remove immediate invalidate() from closeAll() since it destroys native WebSocket state while Starscream callbacks are still queued on the main dispatch queue. closeAll() is used for temporary lifecycle transitions (backgrounding, network changes) where openAll() later reuses clients. Make invalidateClient() two-phase for legitimate destruction paths (logout, server removal): close first, wait for the close event or a timeout, then invalidate. This ensures queued native callbacks have drained before the delegate is nilled. Fixes MATTERMOST-MOBILE-IOS-XHW Fixes MATTERMOST-MOBILE-IOS-YQG Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ios): harden WebSocket teardown against concurrent access and add tests Move client eviction and timer cleanup before the async waitForClose() in invalidateClient(), preventing concurrent openAll/initializeClient from reaching a client mid-teardown. Wrap both NetworkManager and WebsocketManager invalidation in safeExecute in terminateSession so a throw doesn't abort remaining cleanup. Add tests for waitForClose() (immediate resolve, onClose, timeout) and for closeAll/invalidateClient behavior (no invalidate on close, correct call ordering, missing client handling). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ios): track invalidation errors and guard against stale close callbacks Address PR review feedback: - Make client invalidation critical in terminateSession so failures are tracked in the errors array and visible to callers like SecurityManager. - Guard onWebsocketClose against stale callbacks from an invalidated client whose late native onClose event could clobber a replacement client's connected state and periodic status updates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ios): wait for onClose handler and stop status updates on invalidation Address remaining PR review feedback: - waitForClose() no longer short-circuits on readyState CLOSED, only on conn being undefined. This ensures the onClose handler runs its cleanup (clearing conn, resetting state) before invalidate() proceeds, since readyState can be CLOSED before the onClose callback has fired. - invalidateClient() now explicitly calls stopPeriodicStatusUpdates() during eviction. Previously this only happened via the onWebsocketClose callback, which may not fire if waitForClose() resolves via timeout or if the stale callback guard drops it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ios): guard initializeClient and use instance-based stale callback check - Add early return in initializeClient when the client has been evicted from this.clients, preventing a TypeError if a queued reconnect timer fires after invalidateClient deleted the entry. - Replace the presence-only guard in onWebsocketClose with an instance-based isCurrentClient() check on all callbacks set in createClient. This prevents a late callback from an old client from clobbering a replacement client's state even after the new client is installed at this.clients[serverUrl]. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ios): abort initialize() if teardown started during async gaps Check this.stop after each await point in initialize() (Promise.all for config values and getOrCreateWebSocketClient). If close(true) set the stop flag while initialize() was suspended, bail immediately instead of assigning this.conn and calling open() on a client that is mid-teardown. When bailing after obtaining a native client, invalidate it to prevent leaking the native WebSocket resource. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| draft_upload_manager | ||
| intune_manager | ||
| performance_metrics_manager | ||
| security_manager | ||
| apps_manager.test.ts | ||
| apps_manager.ts | ||
| global_event_handler.ts | ||
| integrations_manager.ts | ||
| network_manager.ts | ||
| network_performance_manager.test.ts | ||
| network_performance_manager.ts | ||
| session_manager.test.ts | ||
| session_manager.ts | ||
| websocket_manager.test.ts | ||
| websocket_manager.ts | ||