@@ -38,7 +38,14 @@ func GetEnv(name string) (string, error) {
3838func InitChromeDp () (chromedpCtx context.Context , cancelFnc context.CancelFunc ) {
3939 log .Printf ("Initializing chromedp..." )
4040 if Headless {
41- chromedpCtx , cancelFnc = chromedp .NewContext (context .Background ())
41+ opts := append (chromedp .DefaultExecAllocatorOptions [:],
42+ chromedp .Flag ("headless" , true ),
43+ chromedp .Flag ("no-sandbox" , true ),
44+ chromedp .Flag ("disable-dev-shm-usage" , true ),
45+ chromedp .Flag ("disable-gpu" , true ),
46+ )
47+ allocCtx , _ := chromedp .NewExecAllocator (context .Background (), opts ... )
48+ chromedpCtx , cancelFnc = chromedp .NewContext (allocCtx )
4249 } else {
4350 allocCtx , _ := chromedp .NewExecAllocator (context .Background ())
4451 chromedpCtx , cancelFnc = chromedp .NewContext (allocCtx )
@@ -168,6 +175,9 @@ func RefreshAstraToken(chromedpCtx context.Context) map[string][]string {
168175 chromedp .WaitVisible (`body` , chromedp .ByQuery ),
169176 chromedp .ActionFunc (func (ctx context.Context ) error {
170177 cookies , err := network .GetCookies ().Do (ctx )
178+ if err != nil {
179+ return err
180+ }
171181 gotToken := false
172182 for _ , cookie := range cookies {
173183 cookieStr = fmt .Sprintf ("%s%s=%s; " , cookieStr , cookie .Name , cookie .Value )
@@ -179,7 +189,7 @@ func RefreshAstraToken(chromedpCtx context.Context) map[string][]string {
179189 if ! gotToken {
180190 return errors .New ("failed to get a new token" )
181191 }
182- return err
192+ return nil
183193 }),
184194 )
185195 if err != nil {
0 commit comments