Skip to content

internal/dependency: Manager.visited persists across top-level traversals, silently skipping dependencies #417

Description

@stevendborrelli

Problem

internal/dependency/manager.go keeps a single visited map (claim() / lines ~53-70 before the interface churn in #170) for the whole lifetime of a dependency.Manager. Every top-level traversal — AddAll, RefreshAll, and AddDependency's addPackage — consults it before recursing, but none of them resets it at entry.

A second top-level call on the same Manager therefore sees every ref as already claimed and returns immediately with no error and no sources: a dependency-schema generation silently becomes a no-op.

Impact

Today most commands build a Manager and run exactly one traversal, so the bug does not fire in the common one-command case. It bites:

  • a retry of a traversal after a transient network/registry failure in the same process — the retry looks successful but generates nothing;
  • any embedding or future refactor that runs two traversals on one Manager (the CollectSources-based merged-generation path landing in Project typescript support #170 has exactly this shape, and its resetVisited history comment documents the hazard);
  • tests that reuse a manager fixture across cases.

Silent skip plus zero error output makes this a hard-to-diagnose failure mode when it does fire.

Suggested fix

Add a resetVisited() that reinitializes the map under the existing visitedMu, and call it at the start of each top-level traversal (AddAll/RefreshAll, AddDependency). ~15 lines plus a regression test asserting a second AddAll returns the same sources as the first instead of nothing.

Notes

A fix for this is already present on stevendborrelli:project-typescript-support (part of PR #170). Filing separately so it can land independently: cherry-pick the hunk onto main if desired, or close this on #170 merge if the fix-in-place in that PR is considered sufficient.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions