@@ -206,19 +206,30 @@ public class OpenFeatureAPI {
206206
207207 private func updateContext( evaluationContext: EvaluationContext ) async {
208208 await unifiedQueue. run ( lastWins: true ) { [ self ] in
209- // Get old context and set new context atomically
209+ // Get old context, set new context, and update status atomically
210210 let ( oldContext, provider) = stateQueue. sync { ( ) -> ( EvaluationContext ? , FeatureProvider ? ) in
211211 let oldContext = self . evaluationContext
212212 self . evaluationContext = evaluationContext
213- self . providerStatus = . reconciling
214- return ( oldContext, self . providerSubject. value)
213+
214+ // Only update status if provider is set
215+ if let provider = self . providerSubject. value {
216+ self . providerStatus = . reconciling
217+ return ( oldContext, provider)
218+ }
219+
220+ return ( oldContext, nil )
221+ }
222+
223+ // Early return if no provider is set - nothing to reconcile
224+ guard let provider = provider else {
225+ return
215226 }
216227
217228 eventHandler. send ( . reconciling( nil ) )
218229
219230 // Call provider's onContextSet - this entire operation is atomic
220231 do {
221- try await provider? . onContextSet (
232+ try await provider. onContextSet (
222233 oldContext: oldContext,
223234 newContext: evaluationContext
224235 )
0 commit comments