Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Getting argument list too long while launching chrome using playwright test #30659

Closed
jithin-tyro opened this issue May 4, 2024 · 16 comments

Comments

@jithin-tyro
Copy link

jithin-tyro commented May 4, 2024

Version

1.42.1

Steps to reproduce

Install chrome latest (124) on Docker file using base image playwright jammy 1.42.1
Run the container to trigger test scripts
Not sure if this is related to playwright or chrome

2024-05-04T17:31:21+10:00 [chrome] › tests/example.spec.ts:3:5 › has title ───────────────────────────────────────────────
2024-05-04T17:31:21+10:00 1 failed
2024-05-04T17:31:21+10:00
2024-05-04T17:31:21+10:00
2024-05-04T17:31:21+10:00 - [pid=55][err] /opt/google/chrome/chrome: line 46: /usr/bin/cat: Success
2024-05-04T17:31:21+10:00 - [pid=55][err] /opt/google/chrome/chrome: line 45: /usr/bin/cat: Success
2024-05-04T17:31:21+10:00 - [pid=55][err] /opt/google/chrome/chrome: line 45: /usr/bin/cat: Argument list too long
2024-05-04T17:31:21+10:00 - [pid=55][err] /opt/google/chrome/chrome: line 46: /usr/bin/cat: Argument list too long
2024-05-04T17:31:21+10:00 - [pid=55] finished temporary directories cleanup
2024-05-04T17:31:21+10:00 - [pid=55] starting temporary directories cleanup
2024-05-04T17:31:21+10:00 - [pid=55]
2024-05-04T17:31:21+10:00 - pid=55
2024-05-04T17:31:21+10:00 - /opt/google/chrome/chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-XXXXXX6A6qi7 --remote-debugging-pipe --no-startup-window

Expected behavior

Test should pass

Actual behavior

Chrome launch failed

Additional context

No response

Environment

System
Linux - npm_config_user_agent=npm/10.7.0 node/v22.1.0 linux x64 workspaces/false
@mxschmitt
Copy link
Member

What is the content of /opt/google/chrome/chrome?

I tried it on my machine inside Docker and with npx playwright install chrome and for me the /opt/google/chrome/chrome is the Google Chrome binary/executable, but for you it seems like its a wrapper bash script which uses cat inside?

How did you install Google Chrome?

@jithin-tyro
Copy link
Author

jithin-tyro commented May 7, 2024

Build

RUN apt-get update && apt-get install -y wget apt-transport-https

RUN apt-get update && apt-get install -y curl unzip libgit2-dev xdg-utils

RUN wget http://archive.ubuntu.com/ubuntu/pool/main/libu/libu2f-host/libu2f-udev_1.1.4-1_all.deb
RUN dpkg -i libu2f-udev_1.1.4-1_all.deb

# Add Google Chrome's repository
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb

# Install Google Chrome
RUN apt-get update && apt-get install -y google-chrome-stable

App container

COPY --from=build-only /usr/bin/google-chrome /usr/bin/google-chrome
COPY --from=build-only /usr/bin/google-chrome /usr/bin/chrome

I used the chrome installed on linux and copied to /usr/bin/chrome path and accessed from there didnt run npx playwright install chrome

As you mentioned if we do npx playwright install chrome - does it install chrome/edge, i thought its just installing chromium

@mxschmitt
Copy link
Member

You can use the cli to also install a stable browser, see here: https://playwright.dev/docs/browsers#google-chrome--microsoft-edge

Could you try that and see if it works?

@jithin-tyro
Copy link
Author

jithin-tyro commented May 7, 2024

yes, i used the cli to install chrome and point there in linux amd as shown in Docker script above, but it failed with above error

if i do npx playwright install chrome shall i get a patched chrome for me to work out the tests in linux, without using chromium, also what would be the path of chrome installation in that case

@mxschmitt
Copy link
Member

I'm not an expert in how Google Chrome is packaged on Linux, but I feel like this is not supported:

COPY --from=build-only /usr/bin/google-chrome /usr/bin/google-chrome
COPY --from=build-only /usr/bin/google-chrome /usr/bin/chrome

since Google Chrome depends on many packages and has more than these files placed on your system, this won't work.

Have you tried doing npx playwright install chrome which will give you Google Chrome inside your "app container"?

Re above:

npx playwright install chrome -> Google Chrome
npx playwright install msedge -> Microsoft Edge
npx playwright install chromium -> Chromium

@jithin-tyro
Copy link
Author

thanks, whats the path where chrome gets installed once we use npx playwright install chrome in Linux and Mac

@mxschmitt
Copy link
Member

On Linux probably in /opt/ and on macOS under /Applications - when you use channels, we automatically lookup the right path for you: https://playwright.dev/docs/api/class-testoptions#test-options-channel

As a user, you only need to do npx playwright install chrome and set the channel to "chrome".

Curios why you need the path - maybe I'm missing something!

@jithin-tyro
Copy link
Author

i am using build and app step in my Docker file, where build will have install permissions and app will just run the tests. Instead of copying whole build inside app, just wanted to copy minimum required files to app, and then run the container

@mxschmitt
Copy link
Member

Yeah this is not supported, browsers require a lot of system dependencies, they won't run on a stock Ubuntu, since the dependencies are not satisfied. So you cannot simply copy a few files in order to make browsers like WebKit/Chromium/Firefox work.

See here on how to install the system dependencies. We recommend using our Docker image since it has all these system dependencies installed (for all the browsers):

@jithin-tyro
Copy link
Author

chrome got launched from the path you suggested, but throws Invalid file descriptor to ICU data received.

<launching> /opt/google/chrome/chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-XXXXXXf1PXmq --remote-debugging-pipe --no-startup-window
2024-05-09T12:11:01+10:00	    Call log:
2024-05-09T12:11:01+10:00	    [pid=55][err] [0509/021100.990012:ERROR:icu_util.cc(223)] Invalid file descriptor to ICU data received.

@mxschmitt
Copy link
Member

Cpuld you provide a full minimal reproduction / your dockerfile which we can run locally?

@jithin-tyro
Copy link
Author

jithin-tyro commented May 9, 2024

## BUILD CONTAINER
FROM mcr.microsoft.com/playwright:v1.43.1-focal AS build-only

WORKDIR /app

COPY . .

RUN npm install -g [email protected]

RUN npm install

RUN apt-get update && apt-get install -y wget apt-transport-https

RUN apt-get update && apt-get install -y curl unzip libgit2-dev xdg-utils

RUN wget http://archive.ubuntu.com/ubuntu/pool/main/libu/libu2f-host/libu2f-udev_1.1.4-1_all.deb
RUN dpkg -i libu2f-udev_1.1.4-1_all.deb

# # Add Google Chrome's repository
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb

# # Install Google Chrome
RUN apt-get update && apt-get install -y google-chrome-stable

RUN npx playwright install chrome

# RUN whereis google-chrome

## APP CONTAINER

FROM mcr.microsoft.com/playwright:v1.43.1-focal

COPY --from=build-only /app/src /app/src/
COPY --from=build-only /app/node_modules /app/node_modules/
COPY --from=build-only /app/package.json /app/
COPY --from=build-only /app/playwright.config.ts /app/
COPY --from=build-only /app/tsconfig.json /app/
COPY --from=build-only /usr/bin/google-chrome /usr/bin/google-chrome
COPY --from=build-only /usr/bin/google-chrome /usr/bin/chrome
COPY --from=build-only /opt/google/chrome/chrome /opt/google/chrome/chrome
COPY --from=build-only /ms-playwright/chromium-1112/chrome-linux/chrome /ms-playwright/chromium-1112/chrome-linux/chrome
COPY --from=build-only /opt/google/chrome/chrome /opt/google/chrome/chrome

WORKDIR /app

CMD npm run test

@mxschmitt
Copy link
Member

mxschmitt commented May 9, 2024

Copying browsers is not supported (as per #30659 (comment) and #30659 (comment)), the following would work for you:

## BUILD CONTAINER
FROM mcr.microsoft.com/playwright:v1.43.1-focal AS build-only

WORKDIR /app

COPY . .

RUN npm install -g [email protected]

RUN npm ci

## APP CONTAINER

FROM mcr.microsoft.com/playwright:v1.43.1-focal

COPY --from=build-only /app/src /app/src/
COPY --from=build-only /app/node_modules /app/node_modules/
COPY --from=build-only /app/package.json /app/
COPY --from=build-only /app/playwright.config.ts /app/
COPY --from=build-only /app/tsconfig.json /app/

WORKDIR /app

RUN npx playwright install chrome

CMD npm run test

Probably not worth splitting it up into two containers for end-to-end tests.

@jithin-tyro
Copy link
Author

chromium build works fine with this docker, but chrome channel still breaks on test run

@mxschmitt
Copy link
Member

We need more information to act on this issue. I would recommend to use a single container, since both of your containers are based on the same image anyways.

The following is what I tried which works for me:

## BUILD CONTAINER
FROM mcr.microsoft.com/playwright:v1.43.1-focal AS build-only

WORKDIR /app

COPY . .

RUN npm install -g [email protected]

RUN npm ci

RUN npx playwright install chrome

CMD npx playwright test

Please provide us a reproduction which we can run locally with expected / actual outcomes.

@yury-s
Copy link
Member

yury-s commented May 17, 2024

Closing per the response above, feel free to open a new issue if it doesn't work.

@yury-s yury-s closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants