Puppeteer always returning errors inside docker container
radz
TRIALOP

a year ago

Hi

I'm trying to deploy an app which uses puppeteer but keep getting the error below.

"Navigation timeout of 30000 ms exceeded"

Here is the dockerfile I'm using

FROM node:lts-alpine AS base

FROM base AS build 
WORKDIR /app
COPY package*.json ./
RUN yarn install --frozen-lockfile
COPY . .
RUN yarn run build


FROM base AS production
RUN apk upgrade --no-cache --available \
    && apk add --no-cache \
    chromium-swiftshader \
    ttf-freefont \
    freetype      

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
WORKDIR /app

COPY package*.json ./
RUN yarn install --frozen-lockfile
COPY --from=build /app/dist ./dist
CMD ["node", "dist/index.js"]

5 Replies

unicodeveloper
PRO

a year ago


Status changed to Awaiting User Response Railway about 1 year ago


radz
TRIALOP

a year ago

Hi, thanks for getting back to me. Unfortunately, this hasn't helped.

Here's my puppeteer setup

    const browser = await puppeteer.launch({
      headless: true,
      args: [
        '--no-sandbox',
        '--disable-gpu',
        '--disable-dev-shm-usage',
        '--remote-debugging-port=9222',
        '--remote-debugging-address=0.0.0.0',
      ],
    })

    const page = await browser!.newPage()

    // await page.goto(url, { waitUntil: 'networkidle2' }) - previous setup
    await page.goto(url, { timeout: 0, waitUntil: 'domcontentloaded' })

    await page.waitForFunction(() => !document.getElementById('loader'), {
      timeout: 30000,
    })

    await sleep(2000)

    const canvasImage = await page.evaluate(() => {
      const canvas = document.querySelector('canvas')
      if (!canvas) {
        throw new Error('No canvas element found')
      }
      return canvas.toDataURL('image/png')
    })

Status changed to Awaiting Railway Response Railway about 1 year ago


unicodeveloper
PRO

a year ago

Quick one, what's your use case with Puppeteer? what are you using it for?


Status changed to Awaiting User Response Railway about 1 year ago


radz
TRIALOP

a year ago

I have a page on my webapp which renders a 3d model from a given url and I'd like to use this page along with puppeteer to capture images for any 3d models I pass in.


Status changed to Awaiting Railway Response Railway about 1 year ago


unicodeveloper
PRO

a year ago

I see. We have examples of using pupppeteer. Check this out https://github.com/brody192/puppeteer-example


Status changed to Awaiting User Response Railway about 1 year ago


a year ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody about 1 year ago


Loading...