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

Cycle detection in moduleDeps and compileModuleDeps #2790

Merged
merged 4 commits into from
Sep 27, 2023
Merged

Conversation

lefou
Copy link
Member

@lefou lefou commented Sep 27, 2023

This is a squashed and rebased version of #2349. It depends on #2789 to properly report and exit Mill with a MillException.

The problem: We currently don't detect cycles in transitive moduleDeps and compileModuleDeps. Cycles in these result in a StackOverflowError.

To solve this, we first need to detect cycles. This is the newly added ModuleUtils.recursive method. Instead of moduleDeps we use the moduleDepsChecked in some places to ensure we checked for cycles before accessing module dependencies.

Unfortunately, we can't easily report the detected cycle at evaluation time, as moduleDeps needs to be evaluated before we can create a task graph (via T.traverse), hence we need an alternative way to propagate the exception. The current approach throws an BuildScriptException which itself derives from the also mill.api.MillException (as part of PR #2789).

In MillMain as well as MillClientMain, our central entry points to Mill, we catch the MillException and report the error to the user.

Pull request: #2790

@lefou lefou changed the base branch from main to millexception September 27, 2023 08:09
@lefou lefou changed the title detect cycles 2 Cycle detection in moduleDeps and compileModuleDeps Sep 27, 2023
Base automatically changed from millexception to main September 27, 2023 18:08
@lefou lefou marked this pull request as ready for review September 27, 2023 19:39
@lefou lefou merged commit 80ff26e into main Sep 27, 2023
37 checks passed
@lefou lefou deleted the detect-cycles-2 branch September 27, 2023 20:46
@lefou lefou added this to the 0.11.5 milestone Sep 27, 2023
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

Successfully merging this pull request may close these issues.

Logical loops in moduleDeps
1 participant