After the update of Freezed 0.12.3, it will be stuck in the file generation process.
it will randomly stop working somewhere...

dev_dependencies:
build_runner: ^1.10.4
freezed: ^0.12.3
dependency_overrides:
analyzer: 0.40.4
dev_dependencies:
freezed: 0.12.2
Could you share a way to reproduce this issue?
Hi @rrousselGit ,
After several tests, I think Freezed does not stop working, it just takes too much time to resolve the priority in the new version.
This problem occurs in nested union/sealed classes and it only happens in the cases contain many sub-sealed classes. And the old version(0.12.2) does not have this problem.
Please consider using the following example(this will make the process seems stuck):
// imports
@freezed
abstract class Root with _$Root {
const factory Root.a(A a) = _A;
const factory Root.b(B b) = _B;
const factory Root.c(C c) = _C;
const factory Root.d(D d) = _D;
const factory Root.e(E e) = _E;
const factory Root.f(F f) = _F;
const factory Root.g(G g) = _G;
const factory Root.h(H h) = _H;
const factory Root.i(I i) = _I;
const factory Root.j(J j) = _J;
const factory Root.k(K k) = _K;
const factory Root.l(L l) = _L;
const factory Root.m(M m) = _M;
const factory Root.n(N n) = _N;
}
// imports
@freezed
abstract class A with _$A {
const factory A.a() = _A;
const factory A.b() = _B;
const factory A.c() = _C;
const factory A.d() = _D;
const factory A.e() = _E;
const factory A.f() = _F;
const factory A.g() = _G;
const factory A.h() = _H;
const factory A.i() = _I;
const factory A.j() = _J;
const factory A.k() = _K;
const factory A.l() = _L;
const factory A.m() = _M;
const factory A.n() = _N;
}
// imports
@freezed
abstract class B with _$B {
const factory B.a() = _A;
const factory B.b() = _B;
const factory B.c() = _C;
const factory B.d() = _D;
const factory B.e() = _E;
const factory B.f() = _F;
const factory B.g() = _G;
const factory B.h() = _H;
const factory B.i() = _I;
const factory B.j() = _J;
const factory B.k() = _K;
const factory B.l() = _L;
const factory B.m() = _M;
const factory B.n() = _N;
}
c.dart to n.dart will have a similar structure and content.
This is likely related to the fix of the InconsistentAnalysisException
Am I right to assume that you had an InconsistentAnalysisException when using 0.12.2?
no, I don't have any Exception when I use Freezed 0.12.2.
I only use Freezed for sealed class function, I didn't use serialization, and so on.
That doesn't answer my question:
What happens if you use freezed 0.12.2 instead of 0.12.3 in your codebase?
I mean nothing happened there, no exceptions caused by Freezed 0.12.2 in my case.
Hi,
I am just confirming I have the same problem.
With:
freezed: 0.12.3
Processing stalls at:
...
[INFO] 37.2s elapsed, 255/271 actions completed.
And there is 1 dart process using 100% cpu.
To get this to stop the process has to be killed.
With:
freezed: 0.12.2
Processing completes normally:
...
[INFO] 59.7s elapsed, 1050/1061 actions completed.
[INFO] Running build completed, took 1m 0s
Sorry, I have not got a simple example of how to recreate the problem, just one large (complexed and untidy) project.
I'm getting the same thing. I ran build_runner with the --verbose flag and freezed just gets stuck on some files. For example, it stuck on a part file that contained @freezed annotations. I deleted this part file, but freezed was again stuck on another file - a test file that didn't contain @freezed annotations. I had to rollback the version to 0.12.2.
Yeah, me too. on 0.12.2 everything works fine, on 0.12.3 build_runner/freezed seems to get stuck forever. Not even STRG-C kills the run, I have to kill the process to stop it.
[FINE] freezed:freezed on lib/model/....dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/model/....dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/model/....dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/api/....dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/api/.....dart:Running FreezedGenerator
[FINE] freezed:freezed on lib/api/../../....dart:Running FreezedGenerator
^C^C^C^C^C^C^C^C/Users/kami/development/flutter/bin/internal/shared.sh: line 210: 22756 Terminated: 15 "$DART" "$@"
Since there's no information and no error logs, it's hard to produce a minimal example. It happens on a closed source project with a lot of freezed classes and other code generators, such as moor_generator.
I'm still on analyzer ^0.39.0. I did suffer from InconsistentAnalysisExceptions when using build_runner >1.10.2 before, so I pinned the previous version on 1.10.2. (which is not compatible with freezed 0.12.3, so I removed the pin to build_runner 1.10.2 on freezed 0.12.3 )
Not sure it's related to 0.12.3, since I'm having the same thing on 0.12.2.
The only change was updating build_runner from ^1.10.1 to ^1.10.6.
freezed: ^0.12.2
build_runner: ^1.10.6
json_serializable: ^3.5.0
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script...
[INFO] Generating build script completed, took 520ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 272ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 982ms
[INFO] Running build...
[INFO] 1.1s elapsed, 0/16 actions completed.
[INFO] 2.1s elapsed, 0/16 actions completed.
[INFO] 3.3s elapsed, 0/16 actions completed.
[INFO] 11.8s elapsed, 0/16 actions completed.
[INFO] 12.9s elapsed, 7/22 actions completed.
[INFO] 4m 46s elapsed, 8/24 actions completed.
[WARNING] No actions completed for 4m 33s, waiting on:
- freezed:freezed on lib/src/converter/configuration_converter.dart
- freezed:freezed on lib/src/converter/built_list_widget_model_converter.dart
- freezed:freezed on lib/src/converter/build_list_device_converter.dart
- freezed:freezed on lib/src/api/twitter/model/twitter_status_model.dart
- freezed:freezed on lib/src/subscriptions/subscription_model.dart
.. and 11 more
[INFO] 4m 53s elapsed, 10/26 actions completed.
[INFO] 4m 55s elapsed, 10/26 actions completed.
[INFO] 4m 57s elapsed, 16/32 actions completed.
[INFO] 4m 58s elapsed, 30/39 actions completed.
[INFO] 5m 10s elapsed, 33/39 actions completed.
[INFO] 5m 19s elapsed, 35/39 actions completed.
[INFO] 5m 20s elapsed, 39/55 actions completed.
[INFO] 5m 21s elapsed, 49/65 actions completed.
[INFO] 5m 22s elapsed, 62/76 actions completed.
[INFO] 5m 24s elapsed, 79/87 actions completed.
[INFO] 5m 25s elapsed, 99/115 actions completed.
[INFO] 5m 26s elapsed, 125/135 actions completed.
[INFO] Running build completed, took 5m 26s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 109ms
[INFO] Succeeded after 5m 26s with 53 outputs (138 actions)
Hope this contribute to find a solution.
Regards
Edit : After adding
freezed: ^0.12.2
build_runner: 1.10.2
json_serializable: ^3.5.0
dependency_overrides:
analyzer: 0.39.17
Generation was under a minute : [INFO] Running build completed, took 44.9s.
Edit2 :
freezed: ^0.12.2
build_runner: 1.10.3
json_serializable: ^3.5.0
dependency_overrides:
analyzer: 0.39.17
Then I had to stop it after 10 minutes...
Unfortunately, I'm facing the same issue.
I had the inconsistency issue before, but now my build runs hang.
Edit :
I confirm that downgrading to 0.12.2 fixed the issue on my side. I still encounter InconsistentAnalysisException: Requested result might be inconsistent with previously returned results errors.
Looking at the source code, maybe this loop is always throwing an error ?
Adding a maximum number of attempt can make the process fail at least.
It won't fix the InconsistentAnalysisException though .. :(
On my side downgrading to 0.12.2 does not help.
And it's strange because I got this today. Yesterday all was working fine.
One of my files has got > 800 lines. And I've renamed and deleted other files.
It stuck for 2-3 minutes at first now I cannot wait longer.
flutter pub run build_runner build --delete-conflicting-outputs --build-filter='./lib/bloc/courses/**' --verbose
I confirm that big files structure wait too long to build. (32 minutes on my 86 files)
https://github.com/rrousselGit/freezed/issues/312#issuecomment-731716405
I've cleaned up the file from other code and Freezed still stuck on it.
Are you sure that using 0.12.2 doesn't help?
Make sure to check your pubspec.lock file to see if you are really using 0.12.2
Are you sure that using 0.12.2 doesn't help?
Make sure to check your pubspec.lock file to see if you are really using 0.12.2
Thank you for fast response, you saved my day!
Yes it was my fault: freezed: ^0.12.2 instead of freezed: 0.12.2
Sorry for the delay.
By giving this another look, I've realized that the issue wasn't related to InconsistentAnalysisError but instead some refactoring I made when fixing the error that caused an infinite loop.
I wrote a fix and will publish it soon
Most helpful comment
Unfortunately, I'm facing the same issue.
I had the inconsistency issue before, but now my build runs hang.
Edit :
I confirm that downgrading to
0.12.2fixed the issue on my side. I still encounterInconsistentAnalysisException: Requested result might be inconsistent with previously returned resultserrors.Looking at the source code, maybe this loop is always throwing an error ?
https://github.com/rrousselGit/freezed/blob/2557188caa6cfbce14ed092cbfa5b38952d96094/packages/freezed/lib/src/utils.dart#L30
Adding a maximum number of attempt can make the process fail at least.
It won't fix the InconsistentAnalysisException though .. :(