Skip to content
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

LateInitializationError: Field 'objectClass' has not been initialized. #3947

Open
felangel opened this issue Dec 18, 2024 · 13 comments
Open

Comments

@felangel
Copy link

felangel commented Dec 18, 2024

Description

dartdoc 8.3.1 throws a LateInitializationError whereas dartdoc 8.3.0 did not (seems to be introduced in #3929).

dart --version
Dart SDK version: 3.6.0 (stable) (Thu Dec 5 07:46:24 2024 -0800) on "macos_arm64"

Reproduction Steps

  1. git clone https://github.com/felangel/bloc.git
  2. cd bloc/packages/hydrated_bloc
  3. dart pub global activate dartdoc
  4. dart pub global run dartdoc
  5. Observe LateInitializationError
Documenting hydrated_bloc...
Discovering libraries...
[------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] (100.00%)

Linking elements...
[-                                                                                                                                                                                                                                   ] (0.63%)
dartdoc 8.3.1 (/Users/felix/.pub-cache/global_packages/dartdoc/bin/dartdoc.dart-3.6.0.snapshot) failed: LateInitializationError: Field 'objectClass' has not been initialized.
#0      PackageGraph.objectClass (package:dartdoc/src/model/package_graph.dart)
#1      Mixin.superclassConstraints.<anonymous closure> (package:dartdoc/src/model/mixin.dart:22:54)
#2      WhereIterator.moveNext (dart:_internal/iterable.dart:461:13)
#3      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:202:26)
#4      new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)
#5      new List.of (dart:core-patch/array_patch.dart:39:18)
#6      Mixin.superclassConstraints (package:dartdoc/src/model/mixin.dart:18:69)
#7      Mixin.superclassConstraints (package:dartdoc/src/model/mixin.dart)
#8      Mixin.inheritanceChain (package:dartdoc/src/model/mixin.dart:35:8)
#9      Mixin.inheritanceChain (package:dartdoc/src/model/mixin.dart)
#10     Class.inheritanceChain (package:dartdoc/src/model/class.dart:36:20)
#11     Class.inheritanceChain (package:dartdoc/src/model/class.dart)
#12     InheritingContainer._inheritedElements.<anonymous closure> (package:dartdoc/src/model/inheriting_container.dart:157:9)
#13     InheritingContainer._inheritedElements (package:dartdoc/src/model/inheriting_container.dart:196:4)
#14     InheritingContainer._inheritedElements (package:dartdoc/src/model/inheriting_container.dart)
#15     InheritingContainer.inheritedMethods (package:dartdoc/src/model/inheriting_container.dart:104:35)
#16     InheritingContainer.instanceMethods (package:dartdoc/src/model/inheriting_container.dart:356:12)
#17     Container.allModelElements (package:dartdoc/src/model/container.dart:59:12)
#18     InheritingContainer._allModelElements (package:dartdoc/src/model/inheriting_container.dart:98:14)
#19     InheritingContainer._allModelElements (package:dartdoc/src/model/inheriting_container.dart)
#20     InheritingContainer.allModelElements (package:dartdoc/src/model/inheriting_container.dart:281:46)
#21     Class.allModelElements (package:dartdoc/src/model/class.dart:22:14)
#22     Class.allModelElements (package:dartdoc/src/model/class.dart)
#23     Library.allModelElements (package:dartdoc/src/model/library.dart:440:46)
#24     Library.allModelElements (package:dartdoc/src/model/library.dart)
#25     PackageGraph._gatherModelElements (package:dartdoc/src/model/package_graph.dart:882:36)
#26     PackageGraph._precacheLocalDocs (package:dartdoc/src/model/package_graph.dart:160:28)
#27     PackageGraph.initializePackageGraph (package:dartdoc/src/model/package_graph.dart:126:11)
#28     PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:120:22)
<asynchronous suspension>
#29     Dartdoc.generateDocsBase (package:dartdoc/src/dartdoc.dart:189:24)
<asynchronous suspension>
#30     Dartdoc.generateDocs (package:dartdoc/src/dartdoc.dart:241:24)
<asynchronous suspension>
#31     Dartdoc.executeGuarded.<anonymous closure> (package:dartdoc/src/dartdoc.dart:273:9)
<asynchronous suspension>
@srawlins
Copy link
Member

Thanks for the detailed report!

@srawlins
Copy link
Member

Can you say what version of Dart you are using?

@felangel
Copy link
Author

Can you say what version of Dart you are using?

No problem!

dart --version
Dart SDK version: 3.6.0 (stable) (Thu Dec 5 07:46:24 2024 -0800) on "macos_arm64"

@srawlins
Copy link
Member

Is this consistently reproducible? I can't reproduce using the steps above.

@srawlins
Copy link
Member

@nex3 can you say if your repro is consistent? I've tried a few times in a row with sass_api and cannot reproduce.

@felangel
Copy link
Author

Is this consistently reproducible? I can't reproduce using the steps above.

I’m able to consistently reproduce this and it was reproducible in my CI as well.

@felangel
Copy link
Author

@srawlins let me know if there's anything else I can do to help. Happy to debug it further on my local machine later today.

@srawlins
Copy link
Member

I have some ideas of how to fix, but I'd love to be able to reproduce locally. I can push some potential fixes to a branch, and if you could global activate dartdoc via -sgit and --git-ref, that would validate the fix.

@felangel
Copy link
Author

I have some ideas of how to fix, but I'd love to be able to reproduce locally. I can push some potential fixes to a branch, and if you could global activate dartdoc via -sgit and --git-ref, that would validate the fix.

Sounds great! Happy to verify the fix -- let me know when you have a branch 👍

@srawlins
Copy link
Member

Thanks much @felangel! The branch is here: https://github.com/srawlins/dartdoc/tree/pre-compute-object

So I think you can activate dartdoc with: dart pub global activate -sgit https://github.com/srawlins/dartdoc.git --git-ref pre-compute-object

🤞 Hope that command works, and hope the fix works!

@felangel
Copy link
Author

@srawlins looks like it's still not fixed on my end unfortunately :(

Before

$ dart pub global activate dartdoc
Package dartdoc is currently active at version 8.3.0.
Downloading packages... . 
  _fe_analyzer_shared 76.0.0 (78.0.0 available)
  analyzer 6.11.0 (7.1.0 available)
> dartdoc 8.3.1 (was 8.3.0)
These packages are no longer being depended on:
- web 1.1.0
Building package executables... (2.2s)
Built dartdoc:dartdoc.
Installed executable dartdoc.
Activated dartdoc 8.3.1.

bloc/packages/hydrated_bloc on  master is 📦 v9.1.5 via 🎯 v3.6.0 
$ dart pub global run dartdoc
Documenting hydrated_bloc...
Discovering libraries...
[-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] (100.00%)

Linking elements...
[-                                                                                                                                                                                                      ] (0.63%)
dartdoc 8.3.1 (/Users/felix/.pub-cache/global_packages/dartdoc/bin/dartdoc.dart-3.6.0.snapshot) failed: LateInitializationError: Field 'objectClass' has not been initialized.
#0      PackageGraph.objectClass (package:dartdoc/src/model/package_graph.dart)
#1      Mixin.superclassConstraints.<anonymous closure> (package:dartdoc/src/model/mixin.dart:22:54)
#2      WhereIterator.moveNext (dart:_internal/iterable.dart:461:13)
#3      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:202:26)
#4      new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)
#5      new List.of (dart:core-patch/array_patch.dart:39:18)
#6      Mixin.superclassConstraints (package:dartdoc/src/model/mixin.dart:18:69)
#7      Mixin.superclassConstraints (package:dartdoc/src/model/mixin.dart)
#8      Mixin.inheritanceChain (package:dartdoc/src/model/mixin.dart:35:8)
#9      Mixin.inheritanceChain (package:dartdoc/src/model/mixin.dart)
#10     Class.inheritanceChain (package:dartdoc/src/model/class.dart:36:20)
#11     Class.inheritanceChain (package:dartdoc/src/model/class.dart)
#12     InheritingContainer._inheritedElements.<anonymous closure> (package:dartdoc/src/model/inheriting_container.dart:157:9)
#13     InheritingContainer._inheritedElements (package:dartdoc/src/model/inheriting_container.dart:196:4)
#14     InheritingContainer._inheritedElements (package:dartdoc/src/model/inheriting_container.dart)
#15     InheritingContainer.inheritedMethods (package:dartdoc/src/model/inheriting_container.dart:104:35)
#16     InheritingContainer.instanceMethods (package:dartdoc/src/model/inheriting_container.dart:356:12)
#17     Container.allModelElements (package:dartdoc/src/model/container.dart:59:12)
#18     InheritingContainer._allModelElements (package:dartdoc/src/model/inheriting_container.dart:98:14)
#19     InheritingContainer._allModelElements (package:dartdoc/src/model/inheriting_container.dart)
#20     InheritingContainer.allModelElements (package:dartdoc/src/model/inheriting_container.dart:281:46)
#21     Class.allModelElements (package:dartdoc/src/model/class.dart:22:14)
#22     Class.allModelElements (package:dartdoc/src/model/class.dart)
#23     Library.allModelElements (package:dartdoc/src/model/library.dart:440:46)
#24     Library.allModelElements (package:dartdoc/src/model/library.dart)
#25     PackageGraph._gatherModelElements (package:dartdoc/src/model/package_graph.dart:882:36)
#26     PackageGraph._precacheLocalDocs (package:dartdoc/src/model/package_graph.dart:160:28)
#27     PackageGraph.initializePackageGraph (package:dartdoc/src/model/package_graph.dart:126:11)
#28     PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:120:22)
<asynchronous suspension>
#29     Dartdoc.generateDocsBase (package:dartdoc/src/dartdoc.dart:189:24)
<asynchronous suspension>
#30     Dartdoc.generateDocs (package:dartdoc/src/dartdoc.dart:241:24)
<asynchronous suspension>
#31     Dartdoc.executeGuarded.<anonymous closure> (package:dartdoc/src/dartdoc.dart:273:9)
<asynchronous suspension>

After

✖ dart pub global activate -sgit https://github.com/srawlins/dartdoc.git --git-ref pre-compute-object
Package dartdoc is currently active at version 8.3.1.
Downloading packages... . 
  _fe_analyzer_shared 76.0.0 (78.0.0 available)
  analyzer 6.11.0 (7.1.0 available)
* dartdoc 8.3.1 from git https://github.com/srawlins/dartdoc.git at 6f1861 (was 8.3.1)
Building package executables... (2.0s)
Built dartdoc:dartdoc.
Installed executable dartdoc.
Activated dartdoc 8.3.1 from Git repository "https://github.com/srawlins/dartdoc.git".

bloc/packages/hydrated_bloc on  master is 📦 v9.1.5 via 🎯 v3.6.0 
$ dart pub global run dartdoc                                                                        
Documenting hydrated_bloc...
Discovering libraries...
[-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] (100.00%)

Linking elements...
[-                                                                                                                                                                                                      ] (0.63%)
dartdoc 8.3.1 (/Users/felix/.pub-cache/global_packages/dartdoc/bin/dartdoc.dart-3.6.0.snapshot) failed: LateInitializationError: Field 'objectClass' has not been initialized.
#0      PackageGraph.objectClass (package:dartdoc/src/model/package_graph.dart)
#1      Mixin.superclassConstraints.<anonymous closure> (package:dartdoc/src/model/mixin.dart:22:54)
#2      WhereIterator.moveNext (dart:_internal/iterable.dart:461:13)
#3      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:202:26)
#4      new _GrowableList.of (dart:core-patch/growable_array.dart:152:26)
#5      new List.of (dart:core-patch/array_patch.dart:39:18)
#6      Mixin.superclassConstraints (package:dartdoc/src/model/mixin.dart:18:69)
#7      Mixin.superclassConstraints (package:dartdoc/src/model/mixin.dart)
#8      Mixin.inheritanceChain (package:dartdoc/src/model/mixin.dart:35:8)
#9      Mixin.inheritanceChain (package:dartdoc/src/model/mixin.dart)
#10     Class.inheritanceChain (package:dartdoc/src/model/class.dart:36:20)
#11     Class.inheritanceChain (package:dartdoc/src/model/class.dart)
#12     InheritingContainer._inheritedElements.<anonymous closure> (package:dartdoc/src/model/inheriting_container.dart:157:9)
#13     InheritingContainer._inheritedElements (package:dartdoc/src/model/inheriting_container.dart:196:4)
#14     InheritingContainer._inheritedElements (package:dartdoc/src/model/inheriting_container.dart)
#15     InheritingContainer.inheritedMethods (package:dartdoc/src/model/inheriting_container.dart:104:35)
#16     InheritingContainer.instanceMethods (package:dartdoc/src/model/inheriting_container.dart:356:12)
#17     Container.allModelElements (package:dartdoc/src/model/container.dart:59:12)
#18     InheritingContainer._allModelElements (package:dartdoc/src/model/inheriting_container.dart:98:14)
#19     InheritingContainer._allModelElements (package:dartdoc/src/model/inheriting_container.dart)
#20     InheritingContainer.allModelElements (package:dartdoc/src/model/inheriting_container.dart:281:46)
#21     Class.allModelElements (package:dartdoc/src/model/class.dart:22:14)
#22     Class.allModelElements (package:dartdoc/src/model/class.dart)
#23     Library.allModelElements (package:dartdoc/src/model/library.dart:440:46)
#24     Library.allModelElements (package:dartdoc/src/model/library.dart)
#25     PackageGraph._gatherModelElements (package:dartdoc/src/model/package_graph.dart:888:36)
#26     PackageGraph._precacheLocalDocs (package:dartdoc/src/model/package_graph.dart:160:28)
#27     PackageGraph.initializePackageGraph (package:dartdoc/src/model/package_graph.dart:126:11)
#28     PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:120:22)
<asynchronous suspension>
#29     Dartdoc.generateDocsBase (package:dartdoc/src/dartdoc.dart:189:24)
<asynchronous suspension>
#30     Dartdoc.generateDocs (package:dartdoc/src/dartdoc.dart:241:24)
<asynchronous suspension>
#31     Dartdoc.executeGuarded.<anonymous closure> (package:dartdoc/src/dartdoc.dart:273:9)
<asynchronous suspension>

@nex3
Copy link
Member

nex3 commented Dec 19, 2024

@nex3 can you say if your repro is consistent? I've tried a few times in a row with sass_api and cannot reproduce.

Yes, the specific steps I laid out seem to reproduce it consistently when using Dart 3.6.0. It does not reproduce with Dart 3.5.x, because pub selects an older version of dartdoc. Once sass/dart-sass#2469 lands you'll probably need to check out an older version of the repo to force it to use Dartdoc 8.3.1.

@wolfenrain
Copy link

I can confirm that the issue only happens on Dart 3.6, we saw this error when running pana in Formz's CI and bumping the CI down to an older Flutter (and Dart) version mitigated it for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants