fix: skip self-referential package dependency edges in workspace graph#230
Merged
branchseer merged 1 commit intomainfrom Mar 12, 2026
Merged
fix: skip self-referential package dependency edges in workspace graph#230branchseer merged 1 commit intomainfrom
branchseer merged 1 commit intomainfrom
Conversation
A package that lists itself as a workspace dependency (e.g. rolldown depending on rolldown for self-testing) caused a self-loop edge in the package dependency graph. This loop propagated to the task execution graph, triggering a false "cycle dependency detected" error when planning any task in that package. Fix by silently skipping self-loop edges when building the package graph. Adds a plan snapshot test covering this scenario. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
fengmk2
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
When a package listed itself as a workspace dependency (e.g.
"rolldown": "workspace:*"insiderolldown's ownpackage.json), running any task in that package would fail with:Why
The workspace package graph is built by reading each
package.jsonand adding a directed edge for every workspace dependency that resolves to another package in the monorepo. There was no guard against the case where a package names itself — the edgeA → Awas added unconditionally, producing a self-loop.That self-loop is a cycle by definition, so the task planner's acyclicity check correctly rejected it — but the error was misleading because the "cycle" was entirely artificial and had nothing to do with the task definitions.
Fix
Skip any edge where the source and destination package are the same. A package depending on itself carries no ordering information, so dropping it is safe and matches how tools like pnpm handle this in practice.
Includes a new plan snapshot test with a fixture that reproduces the scenario.