chromedp: Headless Chrome hangs on Wait() after shutdown

When using the --headless flag using the Wait() method hangs the process after calling Shutdown()

import (
	"context"
	"fmt"
	cdp "github.com/knq/chromedp"
)

type BrowserPage struct {
	URL     *url.URL
	Chrome  *cdp.CDP
	Context context.Context
	Cancel  func()
}

func (b BrowserPage) Close() {
	if err := b.Chrome.Shutdown(b.Context); err != nil {
		fmt.Println("Error on shutdown:", err)
	}
	if err := b.Chrome.Wait(); err != nil {
		fmt.Println("Error while waiting for chrome to termiante:", err)
	}
	b.Cancel()
}

This happens on Chrome Version 59.0.3071.109 (Official Build) (64-bit) on Arch Linux

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

This issue was closed, but was there a fix? It still doesn’t appear to be fixed for me.

For me this issue happened when I was using chromedp in parallel without using pools. I moved to using pools, and it seems to be working. Idk if the “bug” is still there. I’m having memory leaks, and I suspect it’s chromedp

Well, the good news is that the upcoming refactored v2 completely overhauls how Chrome is started and stopped, so I believe this problem should not exist in that new design.

In the meantime, if anyone figures out the root of the problem and a fix for the current chromedp, I’ll be happy to review a patch.