Skip to content

Conversation

@jonathannorris
Copy link
Member

@jonathannorris jonathannorris commented Jun 17, 2025

Improve Client Build Process Resilience and Cache Handling

Summary

Enhances the DevCycle iOS Client SDK to gracefully handle network failures during initialization by leveraging cached configurations, while maintaining appropriate error handling for user operations.

Key Changes

🔧 Client Build Process (setup)

  • ✅ No longer throws errors when network fails but cached config is available
  • ✅ Falls back to cached configuration for offline resilience
  • ❌ Only returns errors when both network fails AND no cache exists

👤 User Operations

  • identifyUser: Uses cached config fallback, only errors if no cache available
  • resetUser: Always returns errors on network failure (requires fresh anonymous user)

🧹 Code Cleanup

  • Removed unused Cache struct and load() method (~50 lines of dead code)
  • Simplified cache service protocol and implementations
  • Combined redundant config checks and improved code flow

🧪 Enhanced Testing

  • Added comprehensive test coverage for offline scenarios
  • Tests verify cache fallback behavior vs. error-first behavior
  • Validates client state protection during failures

Behavior Matrix

Scenario Build identifyUser resetUser
Network success
Network fails + Cache
Network fails + No cache

This ensures the SDK works reliably in offline scenarios while maintaining clear error boundaries for operations that require fresh data.

@jonathannorris jonathannorris requested review from Copilot, jsalaber and kaushalkapasi and removed request for jsalaber June 17, 2025 19:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves offline resiliency for the DevCycle iOS Client SDK by leveraging cached configurations when network operations fail. Key changes include fallback to cached configuration in the build process, refined error propagation for user operations, and enhanced test coverage for offline scenarios.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
DevCycleTests/Networking/DevCycleServiceTests.swift Removed unused cache load function in the mock cache service.
DevCycleTests/Models/DevCycleClientTests.swift Added and modified tests to verify cached config behavior.
DevCycle/Models/Cache.swift Removed the legacy Cache struct and cleaned up cache methods.
DevCycle/DevCycleClient.swift Updated error handling and cache usage during setup, identifyUser, and resetUser operations.

@jonathannorris jonathannorris force-pushed the fix-offline-cache-config branch 2 times, most recently from adbb45a to 2a3e92a Compare June 18, 2025 14:48
Base automatically changed from chore-cleanup-client-build to main June 18, 2025 16:04
@jonathannorris jonathannorris force-pushed the fix-offline-cache-config branch from 2a3e92a to b4b04dd Compare June 18, 2025 16:04
@jonathannorris jonathannorris merged commit 9463dd1 into main Jun 19, 2025
15 checks passed
@jonathannorris jonathannorris deleted the fix-offline-cache-config branch June 19, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants