-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with analyzer 0.40.5, InconsistentAnalysisException #941
Comments
Thanks Alan. That's a new one to me ... @scheglov could you give any pointers on why we might get |
See #923 (comment) Also I now managed to generate with The problem was caused by one of |
Yea, as soon as I set |
You would get |
@scheglov I'm stuck--any chance you could take a look please? Repro here: https://github.com/davidmorgan/built_value.dart/tree/publishable-null-safety
--the generator code doesn't get to decide when (Sorry for the horrible repro--built_value has been red on travis for a long time because of null safety being behind a flag, I'm currently working on getting it green again but ran into this issue). |
I changed the dependency_overrides:
analyzer:
path: /Users/scheglov/Source/Dart/sdk.git/sdk/pkg/analyzer So, I can change The result: [WARNING] built_value_generator:built_value on test/generics_nnbd_test.dart:
[new session][#0 new AnalysisSessionImpl (package:analyzer/src/dart/analysis/session.dart:38:39)
#1 AnalysisDriver._createNewSession (package:analyzer/src/dart/analysis/driver.dart:1563:23)
#2 AnalysisDriver._changeHook (package:analyzer/src/dart/analysis/driver.dart:1215:5)
#3 FileTracker.changeFile (package:analyzer/src/dart/analysis/file_tracker.dart:129:16)
#4 AnalysisDriver._changeFile (package:analyzer/src/dart/analysis/driver.dart:1207:18)
#5 AnalysisDriver.changeFile (package:analyzer/src/dart/analysis/driver.dart:477:5)
#6 BuildAssetUriResolver.performResolve (package:build_resolvers/src/build_asset_uri_resolver.dart:79:16)
<asynchronous suspension>
#7 PerActionResolver._resolveIfNecessary.<anonymous closure> (package:build_resolvers/src/resolver.dart:124:11)
<asynchronous suspension>
#8 Pool.withResource (package:pool/pool.dart:127:14)
<asynchronous suspension>
#9 PerActionResolver.isLibrary (package:build_resolvers/src/resolver.dart:91:5)
<asynchronous suspension>
#10 _Builder.build (package:source_gen/src/builder.dart:73:10)
<asynchronous suspension>
#11 runBuilder.buildForInput (package:build/src/generate/run_builder.dart:55:7)
<asynchronous suspension>
#12 Future.wait.<anonymous closure> (dart:async/future.dart)
<asynchronous suspension>
#13 scopeLogAsync.<anonymous closure> (package:build/src/builder/logging.dart)
<asynchronous suspension>
]
[SEVERE] built_value_generator:built_value on lib/collections_nnbd.dart:
Unknown error in BuiltValueGenerator for /end_to_end_test/lib/collections_nnbd.dart. #0 AnalysisSessionImpl._checkConsistency (package:analyzer/src/dart/analysis/session.dart:148:7)
#1 AnalysisSessionImpl.getParsedLibraryByElement (package:analyzer/src/dart/analysis/session.dart:95:5)
#2 SerializerSourceClass.parsedLibrary (package:built_value_generator/src/serializer_source_class.dart:39:31)
#3 _$SerializerSourceClass.parsedLibrary (package:built_value_generator/src/serializer_source_class.g.dart:48:33)
#4 SerializerSourceClass.serializerDeclaration (package:built_value_generator/src/serializer_source_class.dart:108:18)
#5 _$SerializerSourceClass.serializerDeclaration (package:built_value_generator/src/serializer_source_class.g.dart:70:41)
#6 SerializerSourceClass.computeErrors (package:built_value_generator/src/serializer_source_class.dart:255:11)
#7 SerializerSourceLibrary.generateCode.<anonymous closure> (package:built_value_generator/src/serializer_source_library.dart:138:43)
#8 MappedIterator.moveNext (dart:_internal/iterable.dart:392:20)
#9 new List.from (dart:core-patch/array_patch.dart:38:29)
#10 new List.of (dart:core-patch/array_patch.dart:68:17)
#11 Iterable.toList (dart:core/iterable.dart:404:12)
#12 SerializerSourceLibrary.generateCode (package:built_value_generator/src/serializer_source_library.dart:139:10)
#13 BuiltValueGenerator.generate (package:built_value_generator/built_value_generator.dart:30:48)
#14 _generate (package:source_gen/src/builder.dart:323:33)
<asynchronous suspension>
#15 Stream.toList.<anonymous closure> (dart:async/stream.dart)
<asynchronous suspension>
InconsistentAnalysisException: Requested result might be inconsistent with previously returned results So, we see that |
Thanks Konstantin! Much appreciated. I am suspicious about this recent change to dart-lang/build@c1d82b4#diff-329dca0f34609c00795a91dafd45cf73040588d6fdb37d5839231980523b0ab3 --but it's end of day so I will dig further tomorrow. |
After reading dart-lang/sdk#43744 I checked for flakiness; because of cache in
--and per the repro I linked to above, it is flaky, i.e. it sometimes succeeds. I also noticed I can simplify by making the generator immediately call the thing that's failing:
and now it looks like this always fails rather than being flaky. @jakemac53 @natebosch any ideas please? |
Ya this is a known issue that was always potentially present but just happens more often now. The problem and workaround (which isn't great) are listed here dart-lang/build#2634 (comment). |
Thanks Jake! I tried the workaround--then tried a bit harder ;) once wasn't enough, I ended up with
at the start of |
Ya, its sad because we know here that the session won't be invalid in any meaningful way, but have no way of overriding the behavior :(. |
I wonder if the same information that we used to get from the |
If this fix/workaround gonna get released soon? I have a lot of built_value models, and a lot of them fail to get built due to the above error. |
It should be possible to make it work by using Unfortunately it's hard to do a release right now because of the migration to null safety: there is a circular dependency between |
You can try: dependency_overrides:
analyzer: 0.40.5
build_runner: 1.10.2 |
I already have a pin on analyzer 0.41.1, but I still get a ton of I'll try pinning build runner as well. |
Thank you both for replying so quick! The pin on build_runner did the trick! 🎉 |
Update analyzer dependency to allow all versions until 0.41.1. Issue #227 reports that 'lib/main.dart' is skipped during code generation; this PR fixes that. Issue #198 about InconsistentAnalysisException re-emerged with analyzer 0.40.5, workaround from google/built_value.dart#941 adopted. This PR also adds // @Dart=2.9 to tests, because they do not get the language version from the pubspec.yaml. Prepare for publishing as 2.2.9.
I had this as well, even when pinning |
This issue should be resolved on the latest build_runner and built_value now, try removing the pinning and ensure you are on the latest? @davidmorgan did the change to use the provided parsed ast libraries get published for sure? |
It was only published in the last few days as |
But I take it that 8.x is not released yet (at least it appears it isn't), and I assume it's tied to the next big Flutter/Dart release with null safety. So the pins have to stay until then. |
|
@davidmorgan I still don't think that will work if you're the stable branch of Flutter, since that requires Dart 2.10, and |
Got it--yes, you are correct, it won't work with a Flutter version pinned before 2.12. |
Note that this will only work on dev Dart sdks as well. It might be worth backporting a fix to the last release that allows 2.10 stable, but that depends on the work involved to do that etc. |
We tend to only run stable, as we have a production app. We'd only consider running We haven't run into any issues after pinning the above, so I guess the question is: is it worth the dev hours to fix something that is about to be phased out anyway. (At least I hope it's about to be phased out, been waiting on null safety for a while 😁) |
We are having this same problem in our team. We still didn't upgrade our codebase to null-safety and we don't expect to do it too soon, so we are stuck in It used to work some weeks ago with @davidmorgan said:
This would be very welcome. |
@mateusfccp you should be able to update your analyzer without migrating to null safety, fwiw. You can use migrated dependencies without migrating yourself. That is, unless you are stuck on an older SDK which doesn't support null safety for some reason. |
@jakemac53 I am stuck with old analyzer because I use some generators that I have to keep pre-null-safety or else it's going to generate null-safe code. I actually have to use some dependencies overrides to keep everything working. If I try to use other |
I haven't had much time for built_value fixes/improvements lately :/ ... I'll try to take a look at this at some point. |
This commit includes the same workaround for google#941 that was merged into the v8.0.0 tag, which can be found here: google@413c263#diff-09e8eaf836a5c00d73676397af852777169bc8f047e6a0d18c9f8aa050fe5f47
…ysisException (#1090) * Back-patch to 7.x to allow analyzer v0.40.x The built_value_generator package at version 7.1.0 depends on `analyzer: '>=0.39.3 <0.40.0'`, which prevents consumers from resolving newer versions of certain build packages. However, built_value_generator is completely compatible with analyzer v0.40.x as-is. So, to allow consumption of built_value* 7.x with newer build packages without also having to upgrade to Dart 2.12+, this commit widens the analyzer range to include v0.40.x. * Backpatch the InconsistentAnalysisException workaround. This commit includes the same workaround for #941 that was merged into the v8.0.0 tag, which can be found here: 413c263#diff-09e8eaf836a5c00d73676397af852777169bc8f047e6a0d18c9f8aa050fe5f47
I haven't dug into this more deeply, but in attempting to run with bleeding edge 2.12 and analyzer 0.40.5 I encountered the following error building one of our packages. It may be something that's going to be an issue in upcoming builds.
[SEVERE] built_value_generator:built_value on lib/src/data/models/attachment.sg.dart:
Error in BuiltValueGenerator for abstract class Attachment implements Built<Attachment*, dynamic>*.
InconsistentAnalysisException: Requested result might be inconsistent with previously returned results
The text was updated successfully, but these errors were encountered: