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]: Docker image says "Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket" but then after 5 minutes of processing, it finally works? #11900

Closed
1 of 2 tasks
lancejpollard opened this issue Feb 12, 2024 · 18 comments

Comments

@lancejpollard
Copy link
Contributor

lancejpollard commented Feb 12, 2024

Minimal, reproducible example

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    headless: true,
    args: [
      '--no-sandbox',
      '--disable-setuid-sandbox',
      '--user-data-dir=/tmp',
    ],
    timeout: 0,
    executablePath: '/usr/bin/google-chrome',
  });
  const page = await browser.newPage();
  await page.goto('https://google.com');
  await page.screenshot({ path: 'google.png' });

  await browser.close();
})();

Error string

Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket

Bug behavior

  • Flaky
  • PDF

Background

I've been trying to convert HTML to PDF using Puppeteer 22.0.0 on an ubuntu:noble Docker image hosted on Google Cloud Run. Finally it is starting to work (even though I have to use those insecure --no-sandbox permissions). But it takes about 5 minutes for the request to complete, first showing that error above, then a few more errors, before it finally works. Everything works fine and fast locally when using against the Docker image locally.

Here are the relevant logs from my Google Cloud Run:

puppeteer:browsers:launcher Launching /usr/bin/google-chrome --allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-field-trial-config --disable-hang-monitor --disable-infobars --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-search-engine-choice-screen --disable-sync --enable-automation --export-tagged-pdf --generate-pdf-document-outline --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold --enable-features=NetworkServiceInProcess2 --headless=new --hide-scrollbars --mute-audio about:blank --no-sandbox --disable-setuid-sandbox --user-data-dir=/tmp --remote-debugging-port=0 {
  detached: true,
  env: { PUPPETEER_LOGLEVEL: 'warn' },
  stdio: [ 'pipe', 'pipe', 'pipe' ]
}
puppeteer:browsers:launcher Launched 77
[77:99:0212/184919.101915:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
... 2 minutes pass ...
[77:103:0212/185058.541101:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:103:0212/185058.545833:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:99:0212/185058.659905:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185058.664100:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185058.664193:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185058.664208:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185100.545069:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
[77:99:0212/185100.545120:ERROR:bus.cc(407)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
DevTools listening on ws://127.0.0.1:39321/devtools/browser/c2bc3dd3-e056-4850-80d3-03782d2bbde9
puppeteer:protocol:SEND ► [
  '{"method":"Target.setDiscoverTargets","params":{"discover":true,"filter":[{}]},"id":1}'
]
[77:146:0212/185102.787508:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:146:0212/185102.787592:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:146:0212/185102.787668:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:146:0212/185102.787814:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[77:146:0212/185102.787863:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
puppeteer:protocol:RECV ◀ [
  '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"75B8C5DD3A56E651FB1725FD3E7F6890","type":"page","title":"","url":"about:blank","attached":false,"canAccessOpener":false,"browserContextId":"6533EE3CE11CFE6B1647EE8CCACB8D60"}}}'
]
... then it finally starts to log a lot and work ...

Expectation

It should work instantly when called from the REST API I'm using. The REST API logs appear instantly, the puppeteer stuff takes 2-5+ minutes to run.

Reality

It takes a long time to finally process. I had to boost my Google Cloud Run machine size to 8GB RAM and 4 CPU, and choose the "2nd generation" machine which is probably a lot more expensive.

second

Puppeteer configuration file (if used)

None

Puppeteer version

22.0.0

Node version

20.11.0

Package manager

pnpm

Package manager version

8.15.1

Operating system

Linux

Copy link

This issue was not reproducible. Please check that your example runs locally and the following:

  • Ensure the script does not rely on dependencies outside of puppeteer and puppeteer-core.
  • Ensure the error string is just the error message.
    • Bad:

      Error: something went wrong
        at Object.<anonymous> (/Users/username/repository/script.js:2:1)
        at Module._compile (node:internal/modules/cjs/loader:1159:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
        at Module.load (node:internal/modules/cjs/loader:1037:32)
        at Module._load (node:internal/modules/cjs/loader:878:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
        at node:internal/main/run_main_module:23:47
    • Good: Error: something went wrong.

  • Ensure your configuration file (if applicable) is valid.
  • If the issue is flaky (does not reproduce all the time), make sure 'Flaky' is checked.
  • If the issue is not expected to error, make sure to write 'no error'.

Once the above checks are satisfied, please edit your issue with the changes and we will
try to reproduce the bug again.


Analyzer run

@lancejpollard
Copy link
Contributor Author

lancejpollard commented Feb 12, 2024

What do I have to do to get the dbus thing working, I don't know anything about what dbus is. I was getting #10556 error, but setting the timeout: 0 fixed that part. I also saw #10153 but didn't feel it addressed or solved my current issue.

I cache the puppeteer browser instance in JS, and after that, it takes 2 seconds to process the PDF. So that part is good. But then it is sporadic, sometimes it still again takes 5 minutes, sometimes 2 seconds.

My latest Dockerfile is this:

# base image has a lot of unrelated CLI tools installed, based on ubuntu:noble
FROM --platform=linux/amd64 ghcr.io/myorg/mybaseimage:latest

ENV NODE_ENV development
RUN mkdir -p /home/app
WORKDIR /home/app
ENV PORT 8080
COPY *.yaml ./
COPY *.json ./

RUN apt-get update \
  && apt-get install -y wget gnupg \
  && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
  && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
  && apt-get update \
  && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
    --no-install-recommends \
  && rm -rf /var/lib/apt/lists/*

# Commenting this back in causes it to fully fail I think.
# ENV DBUS_SESSION_BUS_ADDRESS autolaunch:

RUN pnpm install

#  && groupadd -r app && useradd -r -g app -G audio,video app \
#   && mkdir -p /home/app/Downloads \
#   && chown -R app:app /home/app \
#   && chown -R app:app /tmp

# USER app

COPY code/ code
RUN pnpm make
EXPOSE ${PORT}
CMD [ "sh", "-c", "pnpm host"]

@OrKoN
Copy link
Collaborator

OrKoN commented Feb 12, 2024

dbus should not be required (it works locally with the same docker image, right?) but you can configure dbus in the following way https://github.com/web-platform-tests/wpt/pull/42241/files How fast is the disk on this environment? It looks like launching chrome is slow there and you can probably reproduce the slowness without using Puppeteer. I don't think this is Puppeteer's bug: Puppeteer only can connect to the browser once "DevTools listening on ..." is printed.

@OrKoN OrKoN closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2024
@lancejpollard
Copy link
Contributor Author

@OrKoN correct, I can run with same docker image locally on my Mac M3. I was going to try this https://stackoverflow.com/questions/42898262/run-dbus-daemon-inside-docker-container but unless you say it's unnecessary.

The disk is fast, it writes 5mb files in an instant, but for some reason puppeteer is slow. I would call this a bug because puppeteer isn't working correctly in this environment.

@lancejpollard
Copy link
Contributor Author

@OrKoN as you can see from my Dockerfile, I already tried configuring dbus and it failed:

# Commenting this back in causes it to fully fail I think.
ENV DBUS_SESSION_BUS_ADDRESS autolaunch:

@OrKoN
Copy link
Collaborator

OrKoN commented Feb 12, 2024

you also need to install dbus and start the dbus service.

@lancejpollard
Copy link
Contributor Author

lancejpollard commented Feb 12, 2024

@OrKoN how do I do that? And why would it fail at first, then work 5 minutes later?

@lancejpollard
Copy link
Contributor Author

lancejpollard commented Feb 12, 2024

@OrKoN how do I do this for pnpm with the custom google-chrome executable installed? I see no .local-chromium anywhere.

# cd to the downloaded instance
cd <project-dir-path>/node_modules/puppeteer/.local-chromium/linux-<revision>/chrome-linux/
sudo chown root:root chrome_sandbox
sudo chmod 4755 chrome_sandbox
# copy sandbox executable to a shared location
sudo cp -p chrome_sandbox /usr/local/sbin/chrome-devel-sandbox
# export CHROME_DEVEL_SANDBOX env variable
export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox
$ ls -lhaF node_modules/puppeteer
lrwxr-xr-x  1 lancepollard  staff    62B Feb 12 12:41 node_modules/puppeteer@ -> .pnpm/puppeteer@22.0.0_typescript@5.3.3/node_modules/puppeteer
Screenshot 2024-02-12 at 12 46 23 PM

@OrKoN
Copy link
Collaborator

OrKoN commented Feb 12, 2024

for dbus, see the Dockerfile https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile

@OrKoN
Copy link
Collaborator

OrKoN commented Feb 12, 2024

For the sandbox,

# cd to Puppeteer cache directory (adjust the path if using a different cache directory).
cd ~/.cache/puppeteer/chrome/linux-<version>/chrome-linux64/
sudo chown root:root chrome_sandbox
sudo chmod 4755 chrome_sandbox
# copy sandbox executable to a shared location
sudo cp -p chrome_sandbox /usr/local/sbin/chrome-devel-sandbox
# export CHROME_DEVEL_SANDBOX env variable
export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox

I don't think it is part of the regular Chrome so you need to install the version that comes with Puppeteer.

@lancejpollard
Copy link
Contributor Author

@OrKoN can you share the full set of commands that will get it fully working with pnpm?

So you're saying I don't need this anymore?

RUN apt-get update \
  && apt-get install -y wget gnupg \
  && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
  && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
  && apt-get update \
  && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
    --no-install-recommends \
  && rm -rf /var/lib/apt/lists/*

What about these, do I need the user and dbus stuff?

RUN apt-get install -y dbus
RUN dbus-daemon --system

RUN pnpm install && groupadd -r app && useradd -r -g app -G audio,video app \
  && mkdir -p /home/app/Downloads \
  && chown -R app:app /home/app \
  && chown -R app:app /tmp

Nice! cd ~/.cache/puppeteer/chrome/linux-<version>/chrome-linux64/ exists on my system, yay finally.

@lancejpollard
Copy link
Contributor Author

lancejpollard commented Feb 12, 2024

@OrKoN here is the final dockerfile I am trying, does it look correct?

FROM --platform=linux/amd64 ghcr.io/myorg/mybase:latest

ENV NODE_ENV development
RUN mkdir -p /home/app
WORKDIR /home/app
ENV PORT 8080
COPY *.yaml ./
COPY *.json ./

RUN apt-get update \
  && apt-get install -y wget gnupg \
  && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
  && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
  && apt-get update \
  && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
    --no-install-recommends \
  && rm -rf /var/lib/apt/lists/*

ENV DBUS_SESSION_BUS_ADDRESS autolaunch:

# RUN sysctl -w kernel.unprivileged_userns_clone=1
RUN apt-get install -y dbus
RUN dbus-daemon --system

ENV DBUS_SESSION_BUS_ADDRESS autolaunch:

RUN pnpm install

# cd to Puppeteer cache directory (adjust the path if using a different cache directory).
RUN cd ~/.cache/puppeteer/chrome && cd $(ls | grep linux-*) && cd chrome-linux64 \
  && chown root:root chrome_sandbox \
  && chmod 4755 chrome_sandbox \
  # copy sandbox executable to a shared location
  && cp -p chrome_sandbox /usr/bin/chrome-devel-sandbox

# export CHROME_DEVEL_SANDBOX env variable
ENV CHROME_DEVEL_SANDBOX /usr/bin/chrome-devel-sandbox

RUN groupadd -r app && useradd -r -g app -G audio,video app \
  && mkdir -p /home/app/Downloads \
  && chown -R app:app /home/app \
  && chown -R app:app /tmp

USER app

COPY code/ code
RUN pnpm make
ENV NODE_ENV production
EXPOSE ${PORT}
CMD [ "sh", "-c", "pnpm host"]

P.S., I am still getting this, even locally:

[150:223:0212/214700.409383:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: Connection refused
[150:223:0212/214700.410006:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: Connection refused
[150:219:0212/214700.423224:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: Connection refused
[150:219:0212/214700.423644:ERROR:bus.cc(407)] Failed to connect to the bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[150:219:0212/214700.423704:ERROR:bus.cc(407)] Failed to connect to the bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[150:219:0212/214700.423795:ERROR:bus.cc(407)] Failed to connect to the bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[150:219:0212/214700.423807:ERROR:bus.cc(407)] Failed to connect to the bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[150:219:0212/214700.700848:ERROR:bus.cc(407)] Failed to connect to the bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[150:219:0212/214700.701027:ERROR:bus.cc(407)] Failed to connect to the bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
DevTools listening on ws://127.0.0.1:36523/devtools/browser/43627f8e-5477-447b-ac5a-4dd8e9b158f9
[150:284:0212/214701.898204:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: Connection refused
[150:284:0212/214701.900209:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: Connection refused
[150:284:0212/214701.900780:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: Connection refused
[150:284:0212/214701.900876:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: Connection refused
[150:284:0212/214701.900964:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: Connection refused

That occurs after 1 invocation of await puppeteer.launch() still with --no-sandbox.

@lancejpollard
Copy link
Contributor Author

@OrKoN I am still setting the executionPath in the puppeteer.launch() call to /usr/bin/google-chrome, seeing these logs:

puppeteer:browsers:launcher Launching /usr/bin/google-chrome ... args ...

Should I change that executionPath to /usr/local/sbin/chrome-devel-sandbox instead now?

@lancejpollard
Copy link
Contributor Author

cc @OrKoN https://www.reddit.com/r/linuxquestions/comments/1aq6826/how_to_start_dbus_on_dockerlinux_failed_to/ If you know how to get dbus working, that would be great.

@lancejpollard
Copy link
Contributor Author

lancejpollard commented Feb 14, 2024

I added some logs to puppeteer-core, and here is the timing of what it takes on local using the Docker image:

01:04:36 PuppeteerNode#launch
01:04:36 ChromeLauncher#computeLaunchArguments complete
01:04:36 ProductLauncher#launch after browserProcess
01:04:36 ProductLauncher#launch not use pipe
01:04:37 DevTools listening on ws://127.0.0.1:9222/devtools/browser/15906f4b-1879-4b1b-91ad-3f2b22cae798
01:04:37 NodeWebSocketTransport#new ws://127.0.0.1:9222/devtools/browser/15906f4b-1879-4b1b-91ad-3f2b22cae798 undefined
01:04:38 NodeWebSocketTransport#new open ws://127.0.0.1:9222/devtools/browser/15906f4b-1879-4b1b-91ad-3f2b22cae798 undefined
01:04:38 ProductLauncher#launch after not use pipe
01:04:38 ProductLauncher#launch CdpBrowser._create
01:04:38 CdpBrowser._create
01:04:38 [211:344:0214/010438.508107:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.DBus.Properties.Get: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
01:04:38 [211:344:0214/010438.514520:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.UPower.GetDisplayDevice: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
01:04:38 [211:344:0214/010438.514885:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.UPower.EnumerateDevices: object_path= /org/freedesktop/UPower: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.UPower was not provided by any .service files
01:04:38 CdpBrowser._create commplete
01:04:38 ProductLauncher#launch CdpBrowser._create complete
01:04:38 ProductLauncher#launch after create connection
01:04:38 ProductLauncher#launch after wait for target

Here's what I see in production, need to add more thorough logs:

2024-02-13 17:11:14.515 PST PuppeteerNode#launch
2024-02-13 17:11:14.517 PST ChromeLauncher#computeLaunchArguments complete
2024-02-13 17:11:14.523 PST puppeteer:browsers:launcher Launched 88
2024-02-13 17:11:14.523 PST ProductLauncher#launch after browserProcess
2024-02-13 17:11:14.523 PST ProductLauncher#launch not use pipe
2024-02-13 17:12:47.129 PST DevTools listening on ws://127.0.0.1:9222/devtools/browser/d9f8e616-7989-4095-b578-c1ffee8db673
2024-02-13 17:12:47.131 PST NodeWebSocketTransport#new ws://127.0.0.1:9222/devtools/browser/d9f8e616-7989-4095-b578-c1ffee8db673
2024-02-13 17:12:49.967 PST NodeWebSocketTransport#new open ws://127.0.0.1:9222/devtools/browser/d9f8e616-7989-4095-b578-c1ffee8db673
2024-02-13 17:12:49.968 PST ProductLauncher#launch after not use pipe
2024-02-13 17:12:49.968 PST ProductLauncher#launch CdpBrowser._create

So it hangs at this line:

const browserWSEndpoint = await browserProcess.waitForLineOutput(

That goes to this createReadline thing:

waitForLineOutput(regex: RegExp, timeout = 0): Promise<string> {
if (!this.#browserProcess.stderr) {
throw new Error('`browserProcess` does not have stderr.');
}
const rl = readline.createInterface(this.#browserProcess.stderr);
let stderr = '';
return new Promise((resolve, reject) => {
rl.on('line', onLine);
rl.on('close', onClose);
this.#browserProcess.on('exit', onClose);
this.#browserProcess.on('error', onClose);
const timeoutId =
timeout > 0 ? setTimeout(onTimeout, timeout) : undefined;
const cleanup = (): void => {
if (timeoutId) {
clearTimeout(timeoutId);
}
rl.off('line', onLine);
rl.off('close', onClose);
this.#browserProcess.off('exit', onClose);
this.#browserProcess.off('error', onClose);
};
function onClose(error?: Error): void {
cleanup();
reject(
new Error(
[
`Failed to launch the browser process!${
error ? ' ' + error.message : ''
}`,
stderr,
'',
'TROUBLESHOOTING: https://pptr.dev/troubleshooting',
'',
].join('\n')
)
);
}
function onTimeout(): void {
cleanup();
reject(
new TimeoutError(
`Timed out after ${timeout} ms while waiting for the WS endpoint URL to appear in stdout!`
)
);
}
function onLine(line: string): void {
stderr += line + '\n';
const match = line.match(regex);
if (!match) {
return;
}
cleanup();
// The RegExp matches, so this will obviously exist.
resolve(match[1]!);
}
});

@OrKoN Why would that readline thing be causing slowness on Docker perhaps, any ideas? That is waiting for the chrome executable to return results...

@OrKoN
Copy link
Collaborator

OrKoN commented Feb 14, 2024

@lancejpollard I do not think readline is slow, I think the browser process is slow to start so it prints the line late and Puppeteer has to wait for that before it can do anything. The slow startup usually comes from the slow disk, not enough CPU or not enough memory. You could also try the headless: 'shell' mode which is technically not Chrome but a similar more light-weight browser implementation.

@lancejpollard
Copy link
Contributor Author

@OrKoN FYI for future reference, the slowness was b/c I was running puppeteer "in the background" on Google Cloud Run, which is basically disabled on Cloud Run by default, see https://www.reddit.com/r/googlecloud/comments/1apcpvr/comment/kqghdoa/?utm_source=share&utm_medium=web2x&context=3

@OrKoN
Copy link
Collaborator

OrKoN commented Feb 15, 2024

@lancejpollard oh wow, I was not aware that Cloud Run does that. I though it is just a server. Would you like to open a PR to add a line to troubleshooting.md about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants