chromedp / chromedp

A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic: sync: negative WaitGroup counter

skaslev opened this issue · comments

We're using gotenberg to convert html to pdf and we're seeing occasional panics in chromedp such as

panic: sync: negative WaitGroup counter

goroutine 431735 [running]:
sync.(*WaitGroup).Add(0xc0001c0420?, 0xc000170a80?)
	/usr/local/go/src/sync/waitgroup.go:83 +0xda
sync.(*WaitGroup).Done(...)
	/usr/local/go/src/sync/waitgroup.go:108
github.com/chromedp/chromedp.(*ExecAllocator).Allocate.func2()
	/go/pkg/mod/github.com/chromedp/chromedp@v0.8.5/allocate.go:234 +0xd2
created by github.com/chromedp/chromedp.(*ExecAllocator).Allocate
	/go/pkg/mod/github.com/chromedp/chromedp@v0.8.5/allocate.go:216 +0xdf2

The problem might be caused by that the WaitGroup counter is increased twice here and then decreased by one here and here.

Additionally, on timeout error the WaitGroup counter is decreased again here which might make the counter negative and cause a panic.