Skip to content
Latchkey

Go "panic: test timed out" - Fix in CI

go test enforces a per-binary timeout (10m by default) and panics with a full goroutine dump when exceeded. The dump usually points at a goroutine stuck on a channel, lock, or network call.

What this error means

A test run aborts with panic: test timed out after 10m0s and a goroutine dump. A test hung instead of completing, or the suite legitimately needs more time.

go
panic: test timed out after 10m0s

goroutine 34 [chan receive]:
	example.com/app.TestSync(...)
		sync_test.go:42 +0x...

Common causes

A test hung

A goroutine blocked forever on a channel, lock, or network call, so the suite never finished.

Timeout too low for the suite

A genuinely long suite exceeded the default 10m timeout.

How to fix it

Fix the hang

  1. Read the goroutine dump to find the blocked test and add a timeout or close the channel.
Go
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()

Raise the timeout for long suites

  1. Increase -timeout only when the suite legitimately needs it.
shell
go test -timeout 20m ./...

How to prevent it

  • Bound every blocking operation in tests with a context timeout.
  • Investigate hangs from the goroutine dump rather than just raising -timeout.
  • Split slow suites so each binary finishes within budget.

Frequently asked questions

What causes ""panic: test timed out""?
A goroutine blocked forever on a channel, lock, or network call, so the suite never finished.
How do I fix "panic: test timed out"?
Fix the hang

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card