golang/go · error

failed to find matching goroutines for name: %s

Error message

failed to find matching goroutines for name: %s

What it means

`pprofByGoroutine` filters goroutines by `name` (the function name captured for the goroutine). It returns an error if no goroutine in the trace's summary matches the supplied name. This surfaces inside pprof region/syscall handlers when a name filter yields nothing.

Source

Thrown at src/cmd/trace/pprof.go:60

	}
}

// pprofMatchingGoroutines returns the ids of goroutines of the matching name and its interval.
// If the id string is empty, returns nil without an error.
func pprofMatchingGoroutines(name string, t *parsedTrace) (map[trace.GoID][]interval, error) {
	res := make(map[trace.GoID][]interval)
	for _, g := range t.summary.Goroutines {
		if name != "" && g.Name != name {
			continue
		}
		endTime := g.EndTime
		if g.EndTime == 0 {
			endTime = t.endTime() // Use the trace end time, since the goroutine is still live then.
		}
		res[g.ID] = []interval{{start: g.StartTime, end: endTime}}
	}
	if len(res) == 0 {
		return nil, fmt.Errorf("failed to find matching goroutines for name: %s", name)
	}
	return res, nil
}

// pprofMatchingRegions returns the time intervals of matching regions
// grouped by the goroutine id. If the filter is nil, returns nil without an error.
func pprofMatchingRegions(filter *regionFilter, t *parsedTrace) (map[trace.GoID][]interval, error) {
	if filter == nil {
		return nil, nil
	}

	gToIntervals := make(map[trace.GoID][]interval)
	for _, g := range t.summary.Goroutines {
		for _, r := range g.Regions {
			if !filter.match(t, r) {
				continue
			}
			gToIntervals[g.ID] = append(gToIntervals[g.ID], regionInterval(t, r))

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Open the trace in the viewer's goroutine view and copy the exact name string shown, then filter with that.
  2. If you want all goroutines, pass an empty name (the `name != ""` guard skips filtering).
  3. Ensure the goroutine was named via `runtime/trace.WithRegion`/`runtime/pprof` or that it ran named user code so the runtime could capture a name.

Example fix

// before
name := "worker"        // matches nothing
// after
name := "main.runWorker" // exact name from summary
Defensive patterns

Strategy: validation

Validate before calling

names := map[string]bool{}
for _, g := range t.summary.Goroutines { names[g.Name] = true }
if name != "" && !names[name] {
    return fmt.Errorf("no goroutine named %q; known: %v", name, names)
}

Prevention

When it happens

Trigger: Passing a goroutine name via the viewer/programmatic API that does not match any `g.Name` in `t.summary.Goroutines`; typos in the function name; names that include receiver types or package paths the user didn't include; anonymized/unnamed goroutines (name == "").

Common situations: Filtering a trace by `main.worker` when the goroutine was actually `runtime/pprof.Do`-named or had no name; forgetting the full path like `github.com/x/y/pkg.foo`; querying a trace where the goroutine launched but never executed user code to get a name.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/a0dc3ae5dd2095e6. Report an issue: GitHub.