@@ -131,8 +131,7 @@ final class LDCommonClient {
131131
132132 late final DataSourceManager _dataSourceManager;
133133 late final EnvironmentReport _envReport;
134- late final AsyncSingleQueue <IdentifyResult > _identifyQueue =
135- AsyncSingleQueue ();
134+ late final AsyncSingleQueue <void > _identifyQueue = AsyncSingleQueue ();
136135 late final DataSourceFactoriesFn _dataSourceFactories;
137136
138137 // Modifications will happen in the order they are specified in this list.
@@ -275,7 +274,7 @@ final class LDCommonClient {
275274 // having been set resulting in a crash.
276275 _identifyQueue.execute (() async {
277276 await _startInternal ();
278- return _identifyInternal (_initialUndecoratedContext,
277+ await _identifyInternal (_initialUndecoratedContext,
279278 waitForNetworkResults: waitForNetworkResults);
280279 }).then ((res) {
281280 _startCompleter! .complete (_mapIdentifyResult (res));
@@ -422,52 +421,46 @@ final class LDCommonClient {
422421 return IdentifyError (Exception (message));
423422 }
424423 final res = await _identifyQueue.execute (() async {
425- return _identifyInternal (context,
424+ await _identifyInternal (context,
426425 waitForNetworkResults: waitForNetworkResults);
427426 });
428427 return _mapIdentifyResult (res);
429428 }
430429
431- Future <IdentifyResult > _mapIdentifyResult (
432- TaskResult <IdentifyResult > res) async {
430+ Future <IdentifyResult > _mapIdentifyResult (TaskResult <void > res) async {
433431 switch (res) {
434- case TaskComplete <IdentifyResult >(result : var result ):
435- return result ?? IdentifyComplete ();
436- case TaskShed <IdentifyResult >():
432+ case TaskComplete <void >( ):
433+ return IdentifyComplete ();
434+ case TaskShed <void >():
437435 return IdentifySuperseded ();
438- case TaskError <IdentifyResult >(error: var error):
436+ case TaskError <void >(error: var error):
439437 return IdentifyError (error);
440438 }
441439 }
442440
443- Future <IdentifyResult > _identifyInternal (LDContext context,
441+ Future <void > _identifyInternal (LDContext context,
444442 {bool waitForNetworkResults = false }) async {
445443 if (! context.valid) {
446444 const message =
447445 'LDClient was provided an invalid context. The context will be ignored. Existing flags will be used for evaluations until identify is called with a valid context.' ;
448446 _logger.warn (message);
449- return IdentifyError ( Exception (message) );
447+ throw Exception (message);
450448 }
451449
452- try {
453- await _setAndDecorateContext (context);
454- final completer = Completer <void >();
455- _eventProcessor? .processIdentifyEvent (IdentifyEvent (context: _context));
456- final loadedFromCache = await _flagManager.loadCached (_context);
450+ await _setAndDecorateContext (context);
451+ final completer = Completer <void >();
452+ _eventProcessor? .processIdentifyEvent (IdentifyEvent (context: _context));
453+ final loadedFromCache = await _flagManager.loadCached (_context);
457454
458- if (_config.offline) {
459- return IdentifyComplete () ;
460- }
461- _dataSourceManager.identify (_context, completer);
455+ if (_config.offline) {
456+ return ;
457+ }
458+ _dataSourceManager.identify (_context, completer);
462459
463- if (loadedFromCache && ! waitForNetworkResults) {
464- return IdentifyComplete ();
465- }
466- await completer.future;
467- return IdentifyComplete ();
468- } catch (error) {
469- return IdentifyError (error);
460+ if (loadedFromCache && ! waitForNetworkResults) {
461+ return ;
470462 }
463+ return completer.future;
471464 }
472465
473466 /// Returns the value of flag [flagKey] for the current context as a bool.
0 commit comments