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

Improve circular dependencies error message #412

Open
0ttik opened this issue Oct 24, 2023 · 4 comments · May be fixed by #413
Open

Improve circular dependencies error message #412

0ttik opened this issue Oct 24, 2023 · 4 comments · May be fixed by #413

Comments

@0ttik
Copy link

0ttik commented Oct 24, 2023

We have multiple issues closed and not resolved regarding the circular dependencies. I think it would significantly help to print more extended information when StackOverflow error occurs in case of circular dependency.

Like "stackoverflow error trying to resolve dependecy X for Y".

Issues: #59, #184, #273, #369, etc.

@0ttik
Copy link
Author

0ttik commented Oct 25, 2023

Just to add some context, here's the log of stackoverflow:

[SEVERE] injectable_generator:injectable_config_builder on lib/core/locator/locator.dart:

Stack Overflow
dart:collection                                                                  _LinkedHashSetMixin._add
package:injectable_generator/models/importable_type.dart 20:35                   ImportableType.allImports
package:injectable_generator/models/importable_type.dart 43:26                   ImportableType.hashCode
package:collection/src/equality.dart 190:32                                      ListEquality.hash
package:injectable_generator/models/importable_type.dart 46:22                   ImportableType.hashCode
package:injectable_generator/models/injected_dependency.dart 36:12               InjectedDependency.hashCode
package:collection/src/equality.dart 190:32                                      ListEquality.hash
package:injectable_generator/models/dependency_config.dart 127:22                DependencyConfig.hashCode
dart:collection                                                                  SetBase.difference
package:injectable_generator/code_builder/builder_utils.dart 128:32              _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
.                                                                                ...
.                                                                                ...
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 128:5               _sortByDependents
package:injectable_generator/code_builder/builder_utils.dart 99:3                sortDependencies
package:injectable_generator/code_builder/builder_utils.dart 16:24               new DependencySet
package:injectable_generator/code_builder/library_builder.dart 105:23            new LibraryGenerator
package:injectable_generator/generators/injectable_config_generator.dart 157:23  InjectableConfigGenerator.generateForAnnotatedElement

@0ttik
Copy link
Author

0ttik commented Oct 25, 2023

I will try to make a PR with an improvement for this case.

0ttik added a commit to 0ttik/injectable that referenced this issue Oct 25, 2023
@0ttik 0ttik linked a pull request Oct 27, 2023 that will close this issue
@0ttik
Copy link
Author

0ttik commented Oct 27, 2023

We can also try to do something described in #273 and implement setter injection in case of circular dependency is detected, but that's a different story.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

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

Successfully merging a pull request may close this issue.

1 participant