r/golang • u/SetBrilliant1025 • 6h ago
show & tell I made a goroutine dump reader that groups 5,000 goroutines into a few lines and flags leaks (runs in the browser)
When a Go service hangs or slowly eats memory, I grab /debug/pprof/goroutine?debug=2 and then scroll through thousands of nearly identical stacks trying to spot the pattern. So I built a page that does the scrolling for me:
https://threadline-be-fast.vercel.app/goroutine-dump/
Paste a dump (pprof debug=2, kill -QUIT output, a panic, or debug=1) and it:
- groups goroutines by state and stack, so 312 leaked workers become one line:
312× chan send · main.queryDatabase (handlers.go:41) flags common problems:
- many goroutines stuck sending on one line (the classic leak after the caller gave up on
ctx.Done()) wg.Wait()called before anyone reads the results- lock queues
- readers stuck behind an
RWMutexwriter - nil channels
all goroutines are asleepand the other crashes
- many goroutines stuck sending on one line (the classic leak after the caller gave up on
It all runs in the browser, so the dump never leaves your machine. Open the Network tab and check.
If you have a dump shape it gets wrong, or a pattern you hunt for by hand that it should flag, I'd love to hear it.