Skip to content

GetCircularDependencies HTTP request not cancelled when GetGraph fails #78

@claude

Description

@claude

In cmd/run.go:280-296, fetchGraphWithCircularDeps launches two concurrent goroutines -- one for GetGraph and one for GetCircularDependencies. When GetGraph fails, the function returns early without cancelling the in-flight GetCircularDependencies HTTP request:

gr := <-graphCh
if gr.err != nil {
    return nil, gr.err   // returns here, but circCh goroutine still running
}
cr := <-circCh

Because circCh is buffered (size 1), there is no goroutine leak -- the goroutine will write its result and exit. However, the HTTP request to the circular-dependencies API endpoint continues to run to completion, wasting network bandwidth and API quota on a result that will be discarded.

Fix: derive a cancellable context from the incoming ctx at the top of the function, and call cancel() before returning on error:

ctx, cancel := context.WithCancel(ctx)
defer cancel()

This will abort the in-flight HTTP request as soon as GetGraph fails.

@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