You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug description
I am using playwright golang library to do some automation tasks, I run my golang program in a debian bookworm/trixie container
When i use chromium headless browser, as soon as i close the browser & stop the playwright instance, the headless shell that was invoked goes into zombie mode. This is also causing the container to gradually increase its memory consumption, even though the golang memory consumption(RSS) remains constant.
Attaching the Dockerfile, go.mod, main.go & also some info of the process which are in zombie mode To Reproduce
Program Code
package main
import (
"github.com/playwright-community/playwright-go""github.com/rs/zerolog/log""time"
)
funcmain() {
for {
pw, err:=playwright.Run()
iferr!=nil {
log.Error().Stack().Err(err).Msg("Failed to start Playwright Instance")
}
browser, err:=pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{Headless: playwright.Bool(true)})
iferr!=nil {
log.Error().Stack().Err(err).Msg("Failed to launch browser")
}
page, err:=browser.NewPage()
iferr!=nil {
log.Error().Stack().Err(err).Msg("Failed to create page")
}
_, err=page.Goto("https://playwright.dev")
iferr!=nil {
log.Error().Stack().Err(err).Msg("Failed to goto page")
}
log.Info().Msg("Sleeping for 2 seconds")
time.Sleep(2*time.Second)
err=page.Close(); iferr!=nil {
log.Error().Stack().Err(err).Msg("Failed to close page")
}
err=browser.Close(); iferr!=nil {
log.Error().Stack().Err(err).Msg("Failed to close browser")
}
err=pw.Stop(); iferr!=nil {
log.Error().Stack().Err(err).Msg("Failed to stop Playwright Instance")
}
log.Info().Msg("Sleeping for 10 seconds")
time.Sleep(5*time.Second)
}
}
FROM --platform=$BUILDPLATFORM golang:1.23.3 AS build
WORKDIR /src
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download -x
RUN go install github.com/playwright-community/playwright-go/cmd/playwright@latest && \
PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
playwright install --only-shell --with-deps chromium
ARG TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=bind,target=. \
CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/test
FROM debian:trixie-slim AS final
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN apt-get update && \
apt-get install -y ca-certificates htop procps && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=build /ms-playwright /ms-playwright
COPY --from=build /go/bin/playwright /usr/local/bin/playwright
COPY --from=build /bin/test /bin/
RUN playwright install-deps chromium && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENTRYPOINT [ "/bin/test" ]
Build and Run docker container: docker build -t test . && docker run --name test test
Logs
{"level":"info","time":"2025-01-23T09:16:18Z","message":"Sleeping for 2 seconds"}
{"level":"info","time":"2025-01-23T09:16:20Z","message":"Sleeping for 10 seconds"}
{"level":"info","time":"2025-01-23T09:16:25Z","message":"Sleeping for 2 seconds"}
{"level":"info","time":"2025-01-23T09:16:27Z","message":"Sleeping for 10 seconds"}
ps aux output
.-(~)---------------------------------------------------------------------------------------------------------------------------------------(nc@BMDVNITHEESHC)-
`--> docker exec -it test sh
# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 1229240 8648 ? Ssl 09:25 0:00 /bin/test
root 32 0.0 0.0 0 0 ? Z 09:25 0:00 [headless_shell] <defunct>
root 33 0.0 0.0 0 0 ? Z 09:25 0:00 [headless_shell] <defunct>
root 90 0.0 0.0 2388 1312 pts/0 Ss 09:25 0:00 sh
root 116 0.1 0.0 0 0 ? Z 09:25 0:00 [headless_shell] <defunct>
root 117 0.0 0.0 0 0 ? Z 09:25 0:00 [headless_shell] <defunct>
root 196 0.1 0.0 0 0 ? Z 09:25 0:00 [headless_shell] <defunct>
root 197 0.1 0.0 0 0 ? Z 09:25 0:00 [headless_shell] <defunct>
root 262 0.0 0.0 6000 3076 pts/0 R+ 09:25 0:00 ps aux
The text was updated successfully, but these errors were encountered:
Bug description
I am using playwright golang library to do some automation tasks, I run my golang program in a debian bookworm/trixie container
When i use chromium headless browser, as soon as i close the browser & stop the playwright instance, the headless shell that was invoked goes into zombie mode. This is also causing the container to gradually increase its memory consumption, even though the golang memory consumption(RSS) remains constant.
Attaching the Dockerfile, go.mod, main.go & also some info of the process which are in zombie mode
To Reproduce
docker build -t test . && docker run --name test test
The text was updated successfully, but these errors were encountered: