Skip to content

Commit

Permalink
enable leakless (#1426)
Browse files Browse the repository at this point in the history
* enable leakless

* comment out chrome pid kill code

* make comment more clear
  • Loading branch information
dogancanbakir authored Nov 13, 2023
1 parent 7b08aaf commit e3aeda0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions runner/headless.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/pkg/errors"
fileutil "github.com/projectdiscovery/utils/file"
osutils "github.com/projectdiscovery/utils/os"
processutil "github.com/projectdiscovery/utils/process"
)

// MustDisableSandbox determines if the current os and user needs sandbox mode disabled
Expand All @@ -24,7 +23,10 @@ func MustDisableSandbox() bool {
type Browser struct {
tempDir string
engine *rod.Browser
pids map[int32]struct{}
// TODO: Remove the Chrome PID kill code in favor of using Leakless(true).
// This change will be made if there are no complaints about zombie Chrome processes.
// Reference: https://github.com/projectdiscovery/httpx/pull/1426
// pids map[int32]struct{}
}

func NewBrowser(proxy string, useLocal bool) (*Browser, error) {
Expand All @@ -33,10 +35,10 @@ func NewBrowser(proxy string, useLocal bool) (*Browser, error) {
return nil, errors.Wrap(err, "could not create temporary directory")
}

pids := processutil.FindProcesses(processutil.IsChromeProcess)
// pids := processutil.FindProcesses(processutil.IsChromeProcess)

chromeLauncher := launcher.New().
Leakless(false).
Leakless(true).
Set("disable-gpu", "true").
Set("ignore-certificate-errors", "true").
Set("ignore-certificate-errors", "1").
Expand Down Expand Up @@ -85,7 +87,7 @@ func NewBrowser(proxy string, useLocal bool) (*Browser, error) {
engine := &Browser{
tempDir: dataStore,
engine: browser,
pids: pids,
// pids: pids,
}
return engine, nil
}
Expand Down Expand Up @@ -125,5 +127,5 @@ func (b *Browser) ScreenshotWithBody(url string, timeout time.Duration) ([]byte,
func (b *Browser) Close() {
b.engine.Close()
os.RemoveAll(b.tempDir)
processutil.CloseProcesses(processutil.IsChromeProcess, b.pids)
// processutil.CloseProcesses(processutil.IsChromeProcess, b.pids)
}

0 comments on commit e3aeda0

Please sign in to comment.