rrousselGit / freezed

Code generation for immutable classes that has a simple syntax/API without compromising on the features.
https://pub.dev/packages/freezed
1.93k stars 237 forks source link

No actions completed for XXXs, waiting on `freezed` #804

Open vasilich6107 opened 1 year ago

vasilich6107 commented 1 year ago

Describe the bug While using codegen I'm getting warnings in terminal No actions completed for 21.1s, waiting on

I have monorepo with dozen of packages so if I have 10 of this warnings it costs me +200 sec of pipeline run

[11:18:38]: ▸ [INFO] Generating build script...
[11:18:39]: ▸ [INFO] Generating build script completed, took 503ms
[11:18:40]: ▸ [INFO] Initializing inputs
[11:18:40]: ▸ [INFO] Reading cached asset graph...
[11:18:40]: ▸ [INFO] Reading cached asset graph completed, took 122ms
[11:18:40]: ▸ [INFO] Checking for updates since last build...
[11:18:42]: ▸ [INFO] Checking for updates since last build completed, took 1.2s
[11:18:42]: ▸ [INFO] Running build...
[11:18:43]: ▸ [INFO] 1.0s elapsed, 0/13 actions completed.
[11:18:44]: ▸ [INFO] 2.1s elapsed, 0/13 actions completed.
[11:18:45]: ▸ [INFO] 3.1s elapsed, 0/13 actions completed.
[11:18:46]: ▸ [INFO] 4.2s elapsed, 0/13 actions completed.
[11:18:47]: ▸ [INFO] 5.2s elapsed, 0/13 actions completed.
[11:19:03]: ▸ [INFO] 21.1s elapsed, 0/13 actions completed.
[11:19:03]: ▸ [WARNING] No actions completed for 21.1s, waiting on:
[11:19:03]: ▸ - freezed on lib/src/ui/app_init/connection_state.gen.dart
[11:19:03]: ▸ - freezed on lib/src/ui/app_init/user_data_state.gen.dart
[11:19:03]: ▸ - freezed on lib/src/ui/logout/presentation/cubit/logout_state.gen.dart
[11:19:03]: ▸ - freezed on lib/src/ui/logout/dto/logout_event_model.gen.dart
[11:19:03]: ▸ - freezed on lib/src/ui/logout/domain/model/logout_event_domain_model.gen.dart
[11:19:03]: ▸ .. and 8 more
[11:19:03]: ▸ [INFO] Running build completed, took 21.9s
[11:19:03]: ▸ [INFO] Caching finalized dependency graph...
[11:19:04]: ▸ [INFO] Caching finalized dependency graph completed, took [81]
[11:19:04]: ▸ [INFO] Succeeded after 22.0s with 13 outputs (13 actions)

To Reproduce I do not have clear reproduction steps.

Expected behavior No delays for 20 second

rrousselGit commented 1 year ago

I need a minimal reproducible example this.

Without one, it isn't clear what's happening and could very well be an issue with build_runner or something else.

vasilich6107 commented 1 year ago

Will try to get one. But the error is pretty random. I have a hope that anyone could share the link with existing issue on github from build runner)

Kiruel commented 1 year ago

Got the same here:

[WARNING] No actions completed for 2m 15s, waiting on:
  - freezed on lib/core/types/failures.dart
  - freezed on lib/core/types/success.dart
  - freezed on lib/core/models/track.dart
  - freezed on lib/core/core_binding.dart
  - freezed on lib/core/bindings.dart
  .. and 11 more

freezed: ^2.1.0

Example for failure.dart:

part '../../generated/core/types/failures.freezed.dart';

@Freezed(makeCollectionsUnmodifiable: false)
class Failure with _$Failure {
  const factory Failure.server({
    required StackTrace stacktrace,
  }) = ServerFailure;
  const factory Failure.local({
    required StackTrace stacktrace,
  }) = LocalFailure;
  const factory Failure.generic({
    required StackTrace stacktrace,
  }) = GenericFailure;

 [...] (5 more methods)
}

My build.yaml

    builders:
      freezed:
        options:
          build_extensions: {
            'lib/features/{{}}.dart': 'lib/generated/features/{{}}.freezed.dart',
            'lib/core/{{}}.dart': 'lib/generated/core/{{}}.freezed.dart',
          }
Kiruel commented 1 year ago

I finally find why it's taking so much time. My success.dart file has multi methods factory (~120 factories). It's seems that after 100 methods the build freeze during multiples minutes. But after splitting the file into multiple files the build come back to only 1min. So freezed got a maximum methods per class maybe ?