Moor: Infinite loop on build_runner build

Created on 9 May 2020  Â·  22Comments  Â·  Source: simolus3/moor

I updated flutter at the last version, but now when I try to rebuild:
flutter packages pub run build_runner build

I get an infinite loop:

...
[INFO] 31m 49s elapsed, 1/17 actions completed.
[INFO] 31m 50s elapsed, 1/17 actions completed.
[INFO] 31m 51s elapsed, 1/17 actions completed.
[INFO] 31m 53s elapsed, 1/17 actions completed.
[INFO] 31m 54s elapsed, 1/17 actions completed.
[WARNING] No actions completed for 15.0s, waiting on:
  - moor_generator:moor_generator on lib/clock_fun.dart
  - moor_generator:moor_generator on lib/external/custom_icons.dart
  - moor_generator:moor_generator on lib/fun.dart
  - moor_generator:moor_generator on lib/globals.dart
  - moor_generator:moor_generator on lib/history_tab.dart
  .. and 11 more
...

I tried the commands flutter clean and then -> Packages get

Most helpful comment

This is still a build bug, it just surfaces in moor_generator. Moor can't do anything about this, as the NNBD migration in Dart & Flutter breaks the build analyzer.

Bad state: Unexpected diagnostics

This is dart-lang/build#2731. Running flutter packages upgrade might fix this.

It really helped me. After trying flutter clean, flutter pub get I tried flutter packages upgrade

All 22 comments

Thanks for the report, can you try to run the build with --verbose and see if there's anything suspicious in the output?

C:\flutter\bin\flutter packages pub run build_runner build --delete-conflicting-outputs --verbose

it gives me some early errors about non-nullable, that I guess are not correlated:

Bad state: Unexpected diagnostics:
C:\flutter\bin\cache\dart-sdk\lib\internal\internal.dart:172:16 - This requires the 'non-nullable' language feature to be enabled.

then it goes in the loop:

...
[INFO] Heartbeat:2m 12s elapsed, 1/17 actions completed.
[INFO] Heartbeat:2m 13s elapsed, 1/17 actions completed.
[INFO] Heartbeat:2m 14s elapsed, 1/17 actions completed.
[INFO] Heartbeat:2m 15s elapsed, 1/17 actions completed.
[WARNING] Heartbeat:
No actions completed for 15.1s, waiting on:
  - moor_generator:moor_generator on test/widget_test.dart
  - moor_generator:moor_generator on lib/choose_icon.dart
  - moor_generator:moor_generator on lib/db/db_classes.dart
  - moor_generator:moor_generator on lib/external/custom_icons.dart
  - moor_generator:moor_generator on lib/fun.dart
  .. and 11 more

Interesting. Which Flutter channel and version are you using?

flutter master channel
version 1.19.0-0.0.pre

Right now I downgraded back to the previous one: 1.18.0-13.0.pre and it works fine (it gives me the DaoGenerator error 3-4 times, but at least I can build)

Any good news? I also meet this problem
[√] Flutter: is fully installed. (Channel master, 1.19.0-1.0.pre.26, on Microsoft Windows [Version 10.0.18362.778], locale zh-CN) [√] Android toolchain - develop for Android devices: is fully installed. (Android SDK version 28.0.3) [√] Visual Studio - develop for Windows: is fully installed. (Visual Studio Community 2019 16.3.5) [√] Android Studio: is fully installed. (version 3.6) [√] IntelliJ IDEA Community Edition: is fully installed. (version 2019.2) [√] VS Code: is fully installed. (version 1.40.1) [√] Connected device: is fully installed. (1 available)

(it gives me the DaoGenerator error 3-4 times, but at least I can build)

It would be interesting to see which error is happening here so I can fix it.

So far I couldn't reproduce this behavior locally. If you can share a small repro where this happens, I'd love to take a look.

(it gives me the DaoGenerator error 3-4 times, but at least I can build)

It would be interesting to see which error is happening here so I can fix it.

I am talking about a different issue, this: https://github.com/simolus3/moor/issues/452

It strongly looks like this is an issue with the Dart analyzer and how it's integrated into the build system (see this and the following messages). It got broken by a recent SDK change that's reflected in the master channel of Flutter.

I'll close the issue since it's not a moor bug. If you're affected by this, can you try to add the dependency override for build_resolvers as suggested and see if that works?

```[INFO] Running build...
[INFO] Generating SDK summary...
[SEVERE] moor_generator:moor_generator on lib/Auth&Http/Auth.dart:

Bad state: Unexpected diagnostics:
C:\Program Files\Flutter\bin\cache\pkg\sky_engine\lib\ui\channel_buffers.dart:119:41 - This requires the 'non-nullable' language feature to be enabled.
C:\Program Files\Flutter\bin\cache\pkg\sky_engine\lib\ui\channel_buffers.dart:152:17 - This requires the 'non-nullable' language feature to be enabled.

I'm also facing same problem
when i tried first it is working fine. when i delete that generated file & create a new file it showing this error.
it is go on running 

[INFO] 2m 1s elapsed, 1/17 actions completed.
[WARNING] No actions completed for 15.1s, waiting on:

[INFO] 2m 3s elapsed, 1/17 actions completed.
[INFO] 2m 4s elapsed, 1/17 actions completed.
[INFO] 2m 6s elapsed, 1/17 actions completed.
[INFO] 2m 7s elapsed, 1/17 actions completed.
[INFO] 2m 8s elapsed, 1/17 actions completed.
```

This is still a build bug, it just surfaces in moor_generator. Moor can't do anything about this, as the NNBD migration in Dart & Flutter breaks the build analyzer.

Bad state: Unexpected diagnostics

This is https://github.com/dart-lang/build/issues/2731. Running flutter packages upgrade might fix this.

I get the same errors with the latest flutter upgrade. It finds some "Bad state: Unexpected diagnostics" and then it is waiting on:

If I remove the build-filter option, build_runner simply waits on ALL my dart files.

I ran "flutter clean". Nothing helps.

FLUTTER DOCTOR -V OUTPUT:

[✓] Flutter (Channel stable, 1.20.0, on Mac OS X 10.15.5 19F101, locale en-US)
• Flutter version 1.20.0 at /Users/arne/flutter
• Framework revision 840c9205b3 (14 hours ago), 2020-08-04 20:55:12 -0700
• Engine revision c8e3b94853
• Dart version 2.9.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/arne/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.6, Build version 11E708
• CocoaPods version 1.9.1

[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

COMMAND LINE OUTPUT:

arne@MacBook-Pro-Arne consumer % flutter pub run build_runner build --build-filter '/Users/arne/rebait/consumer/lib/models/*'
[INFO] Generating build script...
[INFO] Generating build script completed, took 343ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 51ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 450ms

[INFO] Running build...
[INFO] Generating SDK summary...
[SEVERE] json_serializable:json_serializable on lib/models/theme.dart:

Bad state: Unexpected diagnostics:
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:119:41 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:152:17 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:88:62 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:153:38 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:186:51 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:133:32 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:154:25 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:18:17 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:64:4 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:168:32 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:47:14 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:159:38 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:132:37 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:118:48 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:19:11 - This requires the 'non-nullable' language feature to be enabled.
[SEVERE] json_serializable:json_serializable on lib/models/theme.dart:

Bad state: Unexpected diagnostics:
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:119:41 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:152:17 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:88:62 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:153:38 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:186:51 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:133:32 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:154:25 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:18:17 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:64:4 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:168:32 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:47:14 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:159:38 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:132:37 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:118:48 - This requires the 'non-nullable' language feature to be enabled.
/Users/arne/flutter/bin/cache/pkg/sky_engine/lib/ui/channel_buffers.dart:19:11 - This requires the 'non-nullable' language feature to be enabled.
[INFO] 2.1s elapsed, 1/2 actions completed.
[INFO] 3.2s elapsed, 1/2 actions completed.
[INFO] 4.3s elapsed, 1/2 actions completed.
[INFO] 5.4s elapsed, 1/2 actions completed.
[INFO] 6.5s elapsed, 1/2 actions completed.
[INFO] 7.6s elapsed, 1/2 actions completed.
[INFO] 8.7s elapsed, 1/2 actions completed.
[INFO] 9.8s elapsed, 1/2 actions completed.
[INFO] 10.9s elapsed, 1/2 actions completed.
[INFO] 11.9s elapsed, 1/2 actions completed.
[INFO] 13.0s elapsed, 1/2 actions completed.
[INFO] 14.1s elapsed, 1/2 actions completed.
[INFO] 15.2s elapsed, 1/2 actions completed.
[WARNING] No actions completed for 15.0s, waiting on:

[INFO] 17.2s elapsed, 1/2 actions completed.
[INFO] 18.2s elapsed, 1/2 actions completed.

@wolframm Does flutter package upgrade really not fix this for you? You could also try to add a dev_dependency on build_resolvers: ^1.3.10 to enforce a compatible version.

I found a workaround as per https://github.com/flutter/flutter/issues/62240

Hopefully they will fix the latest version of Dart analyzer.

I was getting the same issue, but as I observed that is says "waiting on file", I just tried to close all the open files, and eventually after that this loop problems got resolved, started working automatically.

This is still a build bug, it just surfaces in moor_generator. Moor can't do anything about this, as the NNBD migration in Dart & Flutter breaks the build analyzer.

Bad state: Unexpected diagnostics

This is dart-lang/build#2731. Running flutter packages upgrade might fix this.

It really helped me. After trying flutter clean, flutter pub get I tried flutter packages upgrade

I had the same problem, what happened in my case was that my files were capitalized for example: "MyStoreBank.dart", what I did was change to the lower name "my_store_bank.dart" ... doing this the loop stopped and the .g file was created when I ran "flutter pub run build_runner build"

what worked for me is, I just closed all open files, and the infinite loop
automatically started working.

Warm Regards

Pavan Jaju
Proprietor,
Dreambolix
W: www.dreambolix.com
http://www.Dreambolix.com
E: [email protected] | [email protected]
M: +91 997 519 8058
Skype: pavanjaju


The content of this email is confidential and intended for the recipient
specified in message only. It is strictly forbidden to share any part of
this message with any third party, without a written consent of the sender.
If you received this message by mistake, please reply to this message and
follow with its deletion, so that we can ensure such a mistake does not
occur in the future.

On Wed, Aug 19, 2020 at 7:05 AM Arthur Cabral notifications@github.com
wrote:

I had the same problem, what happened in my case was that my files were
capitalized for example: "MyStoreBank.dart", what I did was change to the
lower name "my_store_bank.dart" ... doing this the loop stopped and the .g
file was created when I ran "flutter pub run build_runner build"

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/simolus3/moor/issues/553#issuecomment-675800957, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AONSS4X35IDNBHJDAZGUXJLSBMT5JANCNFSM4M4YEQNA
.

I solved this bug downgrading to moor_ffi: 0.5.0 and flutter 1.18.0-13.0.pre.
But after updating to flutter 1.20, I am back battling with this again.

Now I tried to update the dependencies to the new official ones:

dependencies:
  moor: # use the latest version
  sqlite3_flutter_libs: # Also use the latest version.
  path_provider:
  path:
dev_dependencies:
  moor_generator: # use the latest version
  build_runner:

At the start of the building I get also:

Bad state: Unexpected diagnostics:
C:\src\flutter\bin\cache\dart-sdk\lib\core\uri.dart:3259:39 - Expected an identifier.
[SEVERE] moor_generator:moor_generator on test/widget_test.dart:

Bad state: Unexpected diagnostics:

I tried with moor_flutter: ^3.1.0 and nothing.

To be honest, I am quite frustrated because every time there is a little change moor won't build at all.

To be honest, I am quite frustrated because every time there is a little change moor won't build at all.

I can understand your frustration, but in this case it's not moor causing trouble. The unexpected diagnostics error comes from build_resolvers, the build system just runs them in the context of moor. You would get the same error with every other code generation package too.

Looking at https://github.com/dart-lang/build/issues/2763, it looks like temporarily adding analyzer: 0.39.14 and running flutter packages upgrade should fix this problem.

If you use package:moor/ffi.dart, you don't need to depend on moor_flutter by the way.

This is still a build bug, it just surfaces in moor_generator. Moor can't do anything about this, as the NNBD migration in Dart & Flutter breaks the build analyzer.

Bad state: Unexpected diagnostics

This is dart-lang/build#2731. Running flutter packages upgrade might fix this.

That also works for me using flutter 1.22 and flutter floor

I'm also facing same problem
when i tried write this command "flutter pub run build_runner build" to generate the api_client.g.dart file it showing this error.
it is go on running

`[INFO] 17.7s elapsed, 1/5 actions completed.
[INFO] 18.8s elapsed, 1/5 actions completed.
[INFO] 19.8s elapsed, 1/5 actions completed.
[INFO] 20.9s elapsed, 1/5 actions completed.
[INFO] 22.0s elapsed, 1/5 actions completed.
[INFO] 23.0s elapsed, 1/5 actions completed.
[INFO] 24.1s elapsed, 1/5 actions completed.
[INFO] 25.2s elapsed, 1/5 actions completed.
[INFO] 26.2s elapsed, 1/5 actions completed.
[INFO] 27.3s elapsed, 1/5 actions completed.
[INFO] 28.4s elapsed, 1/5 actions completed.
[INFO] 29.4s elapsed, 1/5 actions completed.
[INFO] 30.5s elapsed, 1/5 actions completed.
[INFO] 31.6s elapsed, 1/5 actions completed.
[WARNING] No actions completed for 15.0s, waiting on:

@MustafaHasria In your case it looks like built_value_generator (that's from built_value and unrelated to moor) is causing the delay. Either way, can you check that you're using the latest version of build_runner (you don't necessarily need 1.12, but 1.11.x would be good).

Was this page helpful?
0 / 5 - 0 ratings