KijeviGombooc
KijeviGombooc

Reputation: 342

Why does the following golang program with package chromedp that runs in a devcontainer only sometimes print "Run started"?

Sometimes the ActionFunc runs, sometiems not, I cannot find out what makes it trigger. I have also tried using Sleeps, but that doens't seem to matter.

The Go code is the following:

package main

import (
    "context"
    "log"
    "os"
    "time"

    "github.com/chromedp/chromedp"
)

func main() {
    log.Default().SetOutput(os.Stdout)
    timeoutCtx, timeoutCancel := context.WithTimeout(context.Background(), 25*time.Second)
    defer timeoutCancel()
    ctx, cancel := chromedp.NewContext(timeoutCtx)
    defer cancel()

    err := chromedp.Run(ctx,
        chromedp.ActionFunc(func(ctx context.Context) error { log.Println("Run started"); return nil }),
    )
    if err != nil {
        log.Fatal(err)
    }

}

The dockerfile of the dev container:

FROM alpine:3.20.3

RUN apk update
RUN apk add --no-cache git
RUN apk add --no-cache go
RUN apk add --no-cache chromium
RUN go install -v github.com/go-delve/delve/cmd/dlv@latest

Upvotes: 1

Views: 35

Answers (0)

Related Questions