hc-pdf-server icon indicating copy to clipboard operation
hc-pdf-server copied to clipboard

hc-pages-plugin timeout error when running hc-pdf-server

Open dadams-800r opened this issue 1 year ago • 4 comments

The server will not fully start - it terminates early with an hc-pages-plugin timeout error.

After building the image with:

docker build --no-cache --platform=linux/amd64 -t hc-pdf-server:latest .

and running the container with:

docker run --platform=linux/amd64 -it -p 8080:8080 hc-pdf-server:latest

I get the following output:

yarn run v1.22.19
$ node dist/src/server.js
pageOptions: {
  userAgent: undefined,
  pageTimeoutMilliseconds: 30000,
  emulateMediaTypeScreenEnabled: false,
  acceptLanguage: undefined,
  viewport: {
    width: 800,
    height: 600,
    deviceScaleFactor: 1,
    isMobile: false,
    isLandscape: false,
    hasTouch: false
  }
}
launchOptions: {
  args: [
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--disable-gpu',
    '--disable-dev-shm-usage'
  ]
}
launchOptions {
  args: [
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--disable-gpu',
    '--disable-dev-shm-usage'
  ]
}

/app/node_modules/avvio/plugin.js:122
      const err = new AVV_ERR_READY_TIMEOUT(name)
                  ^
AvvioError [Error]: Plugin did not start in time: 'hc-pages-plugin'. You may have forgotten to call 'done' function or to resolve a Promise
    at Timeout._onTimeout (/app/node_modules/avvio/plugin.js:122:19)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7) {
  code: 'AVV_ERR_READY_TIMEOUT',
  fn: <ref *1> [AsyncFunction: plugin] {
    default: [Circular *1],
    hcPagesPlugin: [Circular *1],
    [Symbol(skip-override)]: true,
    [Symbol(fastify.display-name)]: 'hc-pages-plugin',
    [Symbol(plugin-meta)]: { fastify: '^4.0.0', name: 'hc-pages-plugin' }
  }
}

Node.js v18.15.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

... and the container terminates.

I am using a MacBook Pro M1 (thus the --platform=linux/amd64 references) for development and testing. Will be using AWS Kubernetes for production deployment once I can get it working locally.

Not sure why the timeout is occurring. I would appreciate any and all guidance on finding a solution.

dadams-800r avatar Mar 09 '23 19:03 dadams-800r

@dadams-800r Thanks for the information. I could see the same error with Puppeteer v19, so I fixed the plugin as well and upgraded to v2.2.1. It seems to work fine on my local environment (Mac M1 Pro) and on CI!

uyamazak avatar Mar 30 '23 01:03 uyamazak

@uyamazak ... Could you please expand on your comment: "I could see the same error with Puppeteer v19, so I fixed the plugin as well and upgraded to v2.2.1."?

I'm getting the same error after pulling down the main branch, building, and then running...


/app/node_modules/avvio/plugin.js:122
      const err = new AVV_ERR_READY_TIMEOUT(name)
                  ^
AvvioError [Error]: Plugin did not start in time: 'hc-pages-plugin'. You may have forgotten to call 'done' function or to resolve a Promise
    at Timeout._onTimeout (/app/node_modules/avvio/plugin.js:122:19)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7) {
  code: 'AVV_ERR_READY_TIMEOUT',
  fn: <ref *1> [AsyncFunction: plugin] {
    default: [Circular *1],
    hcPagesPlugin: [Circular *1],
    [Symbol(skip-override)]: true,
    [Symbol(fastify.display-name)]: 'hc-pages-plugin',
    [Symbol(plugin-meta)]: { fastify: '^4.0.0', name: 'hc-pages-plugin' }
  }
}

dadams-800r avatar Mar 30 '23 15:03 dadams-800r

@dadams-800r It seems it was a different problem and I was able to reproduce it on my M1. Docker on M1 (or ARM) seems to complicate the issue, I will try to switch to using the official Puppeteer images.

https://pptr.dev/guides/docker

uyamazak avatar Apr 12 '23 00:04 uyamazak

@uyamazak i built the image on top of ghcr.io/puppeteer/puppeteer:latest but faced the same error

/app/node_modules/avvio/plugin.js:122
      const err = new AVV_ERR_READY_TIMEOUT(name)
                  ^
AvvioError [Error]: Plugin did not start in time: 'hc-pages-plugin'. You may have forgotten to call 'done' function or to resolve a Promise
    at Timeout._onTimeout (/app/node_modules/avvio/plugin.js:122:19)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7) {
  code: 'AVV_ERR_READY_TIMEOUT',
  fn: <ref *1> [AsyncFunction: plugin] {
    default: [Circular *1],
    hcPagesPlugin: [Circular *1],
    [Symbol(skip-override)]: true,
    [Symbol(fastify.display-name)]: 'hc-pages-plugin',
    [Symbol(plugin-meta)]: { fastify: '^4.0.0', name: 'hc-pages-plugin' }
  }
}

m3di avatar Sep 08 '23 22:09 m3di