Skip to content

bug: circular-deps goroutine not cancelled when graph fetch fails in GetGraphAndCircularDeps #262

@claude

Description

@claude

Problem

In internal/api/client.go (GetGraphAndCircularDeps), two goroutines are launched concurrently — one for the supermodel graph and one for circular dependencies. If the graph request fails, the function returns early at line 568-570 without cancelling the circular-deps goroutine.

The circular-deps goroutine continues polling the API until the caller context is eventually cancelled, wasting API round-trips and holding connections open unnecessarily. Both channels are correctly buffered so there is no goroutine leak, but the goroutine does unnecessary work.

Fix

Introduce a derived cancellable context scoped to GetGraphAndCircularDeps, and cancel it via defer. This covers both the early-return and the happy-path cases:

inner, cancel := context.WithCancel(ctx)
defer cancel()
// pass inner to both pollJob calls instead of ctx

Location

  • internal/api/client.go, lines 530-570 (GetGraphAndCircularDeps)

@claude please implement this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions