-
Notifications
You must be signed in to change notification settings - Fork 3
Description
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