File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ func New(opts Options) (*Browser, error) {
4646 if ! opts .Headless {
4747 allocOpts = append (allocOpts , chromedp .Flag ("headless" , false ))
4848 }
49+ if shouldDisableSandbox () {
50+ allocOpts = append (allocOpts ,
51+ chromedp .Flag ("no-sandbox" , true ),
52+ chromedp .Flag ("disable-setuid-sandbox" , true ),
53+ )
54+ }
4955 if opts .Profile != "" {
5056 allocOpts = append (allocOpts , chromedp .UserDataDir (opts .Profile ))
5157 }
Original file line number Diff line number Diff line change 11package browser
22
3- import "time"
3+ import (
4+ "os"
5+ "runtime"
6+ "time"
7+ )
48
59type Options struct {
610 Headless bool
@@ -42,3 +46,16 @@ func (o Options) normalized() Options {
4246 }
4347 return o
4448}
49+
50+ func shouldDisableSandbox () bool {
51+ if runtime .GOOS != "linux" {
52+ return false
53+ }
54+ if os .Getenv ("KO_BROWSER_NO_SANDBOX" ) != "" {
55+ return true
56+ }
57+ if os .Getenv ("GITHUB_ACTIONS" ) == "true" {
58+ return true
59+ }
60+ return os .Getenv ("CI" ) != ""
61+ }
You can’t perform that action at this time.
0 commit comments