Freezed: InconsistentAnalysisException

Created on 3 Nov 2020  路  7Comments  路  Source: rrousselGit/freezed

Describe the bug
I got this error when running flutter pub run build_runner build --delete-conflicting-outputs --verbose:

[WARNING] freezed:freezed on lib/application/database/create_account/create_account_database_bloc.dart:
Error InconsistentAnalysisException: Requested result might be inconsistent with previously returned results

[WARNING] freezed:freezed on lib/application/database/create_account/create_account_database_bloc.dart:
#0      AnalysisSessionImpl._checkConsistency (package:analyzer/src/dart/analysis/session.dart:146:7)
#1      AnalysisSessionImpl.getParsedLibraryByElement (package:analyzer/src/dart/analysis/session.dart:93:5)
#2      documentationOfParameter (package:freezed/src/utils.dart:8:12)
#3      new Property.fromParameter (package:freezed/src/templates/concrete_template.dart:399:12)
#4      FreezedGenerator._parseConstructorsNeedsGeneration (package:freezed/src/freezed_generator.dart:473:24)
#5      FreezedGenerator.parseElement (package:freezed/src/freezed_generator.dart:239:9)
#6      ParserGenerator.generate (package:freezed/src/parse_generator.dart:29:22)
#7      _generate (package:source_gen/src/builder.dart:323:33)
<asynchronous suspension>
#8      _Builder._generateForLibrary (package:source_gen/src/builder.dart:84:15)
#9      _Builder.build (package:source_gen/src/builder.dart:76:11)
<asynchronous suspension>
#10     runBuilder.buildForInput (package:build/src/generate/run_builder.dart:55:21)
#11     MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
#12     ListIterator.moveNext (dart:_internal/iterable.dart:343:26)
#13     Future.wait (dart:async/future.dart:406:26)
#14     runBuilder.<anonymous closure> (package:build/src/generate/run_builder.dart:61:36)
#15     _rootRun (dart:async/zone.dart:1190:13)
#16     _CustomZone.run (dart:async/zone.dart:1093:19)
#17     _runZoned (dart:async/zone.dart:1630:10)
#18     runZonedGuarded (dart:async/zone.dart:1618:12)
#19     runZoned (dart:async/zone.dart:1547:12)
#20     scopeLogAsync (package:build/src/builder/logging.dart:26:3)
#21     runBuilder (package:build/src/generate/run_builder.dart:61:9)
#22     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:485:19)
#23     _NoOpBuilderActionTracker.trackStage (package:build_runner_core/src/generate/performance_tracker.dart:302:15)
#24     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:483:23)
<asynchronous suspension>
#25     _SingleBuild._runForInput.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart)
#26     NoOpTimeTracker.track (package:timing/src/timing.dart:222:44)
#27     _SingleBuild._runForInput.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:440:22)
#28     Pool.withResource (package:pool/pool.dart:127:28)
<asynchronous suspension>
#29     _SingleBuild._runForInput (package:build_runner_core/src/generate/build_impl.dart:436:17)
#30     _SingleBuild._runBuilder.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:374:38)
#31     MappedIterator.moveNext (dart:_internal/iterable.dart:392:20)
#32     Future.wait (dart:async/future.dart:406:26)
#33     _SingleBuild._runBuilder (package:build_runner_core/src/generate/build_impl.dart:373:36)
#34     _SingleBuild._runPhases.<anonymous closure>.<anonymous closure> (package:build_runner_core/src/generate/build_impl.dart:319:20)
#35     _rootRunUnary (dart:async/zone.dart:1198:47)
#36     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#37     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#38     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#39     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#40     Future._completeWithValue (dart:async/future_impl.dart:529:5)
#41     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#42     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#43     _SingleBuild._matchingPrimaryInputs (package:build_runner_core/src/generate/build_impl.dart)
#44     _rootRunUnary (dart:async/zone.dart:1198:47)
#45     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#46     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#47     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#48     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#49     Future._completeWithValue (dart:async/future_impl.dart:529:5)
#50     Future.wait.<anonymous closure> (dart:async/future.dart:414:23)
#51     _rootRunUnary (dart:async/zone.dart:1198:47)
#52     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#53     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#54     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#55     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#56     Future._completeWithValue (dart:async/future_impl.dart:529:5)
#57     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#58     _rootRun (dart:async/zone.dart:1190:13)
#59     _CustomZone.run (dart:async/zone.dart:1093:19)
#60     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#61     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#62     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#63     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#64     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#65     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:404:11)
#66     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

[SEVERE] freezed:freezed on lib/application/database/create_account/create_account_database_bloc.dart:

InconsistentAnalysisException: Requested result might be inconsistent with previously returned results

which makes build_runner fail

To Reproduce
May be hard to reproduce since it's a bloc in three files and I use Injectable packages inside one of them but here you go:
create_account_database_bloc.dart

part 'create_account_database_bloc.freezed.dart';
part 'create_account_database_event.dart';
part 'create_account_database_state.dart';

/// @nodoc
@injectable
class CreateAccountDatabaseBloc
    extends Bloc<CreateAccountDatabaseEvent, CreateAccountDatabaseState> {
  /// @nodoc
  CreateAccountDatabaseBloc() : super(CreateAccountDatabaseState.initial());

  @override
  Stream<CreateAccountDatabaseState> mapEventToState(
      CreateAccountDatabaseEvent event) async* {
    yield* event.map(
      accountCreatedEVT: (event) async* {},
      userDetailsSavedEVT: (event) async* {},
    );
  }
}

create_account_database_event.dart

part of 'create_account_database_bloc.dart';

/// @nodoc
@freezed
abstract class CreateAccountDatabaseEvent with _$CreateAccountDatabaseEvent {
  /// @nodoc
  const factory CreateAccountDatabaseEvent.accountCreatedEVT(User user) =
      AccountCreated;

  /// @nodoc
  const factory CreateAccountDatabaseEvent.userDetailsSavedEVT(User user) =
      UserDetailsSavedEVT;
}

create_account_database_state.dart

part of 'create_account_database_bloc.dart';

/// @nodoc
@freezed
abstract class CreateAccountDatabaseState with _$CreateAccountDatabaseState {
  /// @nodoc
  const factory CreateAccountDatabaseState({
    @required String email,
  }) = _CreateAccountDatabaseState;

  /// @nodoc
  factory CreateAccountDatabaseState.initial() => CreateAccountDatabaseState(
        email: '',
      );
}

Expected behavior
build_runner should finish with a success

bug needs triage

Most helpful comment

Try overriding the analyzer inside pubspec.yaml if you're using Flutter 1.22.3.

dependency_overrides:
  analyzer: '0.40.4'

All 7 comments

i am getting the same error.i am on the latest sdk 1.22.3

Try overriding the analyzer inside pubspec.yaml if you're using Flutter 1.22.3.

dependency_overrides:
  analyzer: '0.40.4'

@ResoDev thx, it works for me. Do you maybe know why the latest analyzer create this error?

@SSebigo The analyzer caused me a bunch of similar issues over the last few months. I don't know about their cause.

hmm I see, that's unfortunate hopefully it'll be fixed for the next releases. I'll close the issue since it's not a freezed issue after all. Thx again @ResoDev

Sorry I know this is closed, but perhaps the "freezed" code may be reviewed with relation to the following comment to solve the problem more permanently, maybe.
https://github.com/dart-lang/build/issues/2634#issuecomment-670603224

I am searching for a solution https://github.com/rrousselGit/freezed/issues/294

But so far I haven't found a fix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rakakhrl picture rakakhrl  路  6Comments

huafu picture huafu  路  4Comments

linhdogg picture linhdogg  路  4Comments

narcodico picture narcodico  路  6Comments

matiasosuna picture matiasosuna  路  4Comments