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

PDF conversion in Docker image is stuck and fails with timeout after upgrade to v2.5.0 #520

Closed
hofbi opened this issue Apr 17, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@hofbi
Copy link

hofbi commented Apr 17, 2023

Version of Marp Tool

v2.5.0

Operating System

Other (fill out in the environment field)

Environment

How to reproduce

  1. docker run --rm --init -v $PWD:/home/marp/app/ -e LANG=$LANG marpteam/marp-cli slide-deck.md --pdf

Expected behavior

The PDF is generated

Actual behavior

Conversion is stuck for a few minutes and then fails with Failed converting Markdown. (Target.setAutoAttach timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.)

Additional information

No response

@hofbi hofbi added the bug Something isn't working label Apr 17, 2023
@cyril-marpaud
Copy link

Same error in Gitlab-CI since this morning.

image

This used to work just fine last week.

@hofbi
Copy link
Author

hofbi commented Apr 17, 2023

I can confirm and reproduce this for Gitlab CI, Github actions, and locally.

@yhatt yhatt added the help wanted Extra attention is needed label Apr 19, 2023
@yhatt yhatt pinned this issue Apr 19, 2023
@yhatt
Copy link
Member

yhatt commented Apr 19, 2023

We still cannot determine the cause of error. In general, Puppeteer is known as difficult to work on Docker image, so Marp team always recommend to run Marp CLI with installing to the local/CI environment (https://github.com/orgs/marp-team/discussions/375#discussioncomment-4191221).

For debugging Docker image:

  • Add -e DEBUG="*" may help to inspect the process of Chrome.
  • --entrypoint="" -it marpteam/marp-cli /bin/sh to execute shell.

@yhatt yhatt changed the title PDF conversion is stuck and fails with timeout after upgrade to v2.5.0 PDF conversion in Docker image is stuck and fails with timeout after upgrade to v2.5.0 Apr 19, 2023
@spkane
Copy link

spkane commented Apr 28, 2023

I am seeing this same thing with the Markdown conversions to PDF when using the Linux container image via Docker Desktop on an arm64 macOS system.

  • Script Output
[ INFO ] Setting up environment...
[ INFO ] Building HTML slides...
[  INFO ] Converting 1 markdown...
[  INFO ] target.md => target.html
[ INFO ] Building Powerpoint Slides...
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from
          target.md.
[ ERROR ] Failed converting Markdown. (Target.setAutoAttach timed out. Increase
          the 'protocolTimeout' setting in launch/connect calls for a higher
          timeout if needed.)

Using the CLI works around this.

Just to provide some debugging information I then ran:

$ docker container run --rm -e DEBUG="*" -v ${PWD}:/home/marp/app/ -e DEBUG="*"  --entrypoint="" -it marpteam/marp-cli:latest  /bin/sh

/home/marp/app # marp-cli.js target.md --theme-set spkane.css --pptx --allow-local-files

  portfinder:defaultHosts exports._defaultHosts is: [ '0.0.0.0', '127.0.0.1', '172.17.0.2', null ] +0ms
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from
          target.md.
  puppeteer:browsers:launcher Launching /usr/bin/chromium-browser --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-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-blink-features=IdleDetection --enable-features=NetworkServiceInProcess2 --export-tagged-pdf --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --user-data-dir=/tmp/marp-cli-conversion --headless --hide-scrollbars --mute-audio about:blank --export-tagged-pdf --test-type --no-sandbox --disable-features=VizDisplayCompositor --enable-blink-features=ViewTransition --remote-debugging-pipe {
  detached: true,
  env: {
    MARP_USER: 'marp:marp',
    NODE_VERSION: '18.14.1',
    CHROME_PATH: '/usr/bin/chromium-browser',
    HOSTNAME: 'a7214d7438e6',
    DEBUG: '*',
    YARN_VERSION: '1.22.19',
    SHLVL: '1',
    HOME: '/root',
    TERM: 'xterm',
    PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/marp/.cli',
    PWD: '/home/marp/app'
  },
  stdio: [ 'ignore', 'ignore', 'ignore', 'pipe', 'pipe' ]
} +0ms
  puppeteer:browsers:launcher Launched 40 +5ms
  puppeteer:protocol:SEND ► [
  puppeteer:protocol:SEND ►   '{"method":"Target.setDiscoverTargets","params":{"discover":true,"filter":[{"type":"tab","exclude":true},{}]},"id":1}'
  puppeteer:protocol:SEND ► ] +0ms
  puppeteer:protocol:SEND ► [
  puppeteer:protocol:SEND ►   '{"method":"Target.setAutoAttach","params":{"waitForDebuggerOnStart":true,"flatten":true,"autoAttach":true},"id":2}'
  puppeteer:protocol:SEND ► ] +0ms
  puppeteer:error [
  puppeteer:error   ProtocolError: Target.setDiscoverTargets timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
  puppeteer:error       at new Callback (/home/marp/.cli/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:61:35)
  puppeteer:error       at CallbackRegistry.create (/home/marp/.cli/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:106:26)
  puppeteer:error       at Connection._rawSend (/home/marp/.cli/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:216:26)
  puppeteer:error       at Connection.send (/home/marp/.cli/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:210:21)
  puppeteer:error       at new ChromeTargetManager (/home/marp/.cli/node_modules/puppeteer-core/lib/cjs/puppeteer/common/ChromeTargetManager.js:236:14)
  puppeteer:error       at new CDPBrowser (/home/marp/.cli/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.js:139:69)
  puppeteer:error       at CDPBrowser._create (/home/marp/.cli/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser.js:48:25)
  puppeteer:error       at ChromeLauncher.launch (/home/marp/.cli/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:138:61)
  puppeteer:error       at async el (/home/marp/.cli/lib/marp-cli-9fe562c5.js:44:12551)
  puppeteer:error       at async Ll.runBrowser (/home/marp/.cli/lib/marp-cli-9fe562c5.js:44:99267)
  puppeteer:error ] +0ms
  puppeteer:protocol:SEND ► [ '{"method":"Browser.close","id":3}' ] +0ms
[ ERROR ] Failed converting Markdown. (Target.setAutoAttach timed out. Increase
          the 'protocolTimeout' setting in launch/connect calls for a higher
          timeout if needed.)

@rombert
Copy link

rombert commented May 26, 2023

In case this proves useful:

  • adding -e PUPPETEER_HEADLESS_MODE=new does not change the outcome
  • the container uses 100% CPU ( one core ); validated using docker stats and top. The runaway process is chrome itself
  • after the timeout message is printed, chrome keeps running

The full chrome command line is

/usr/lib/chromium/chrome --extra-plugin-dir=/usr/lib/nsbrowser/plugins --ozone-platform-hint=auto --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-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-blink-features=IdleDetection --enable-features=NetworkServiceInProcess2 --export-tagged-pdf --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --user-data-dir=/tmp/marp-cli-conversion --headless=new --hide-scrollbars --mute-audio about:blank --export-tagged-pdf --test-type --no-sandbox --disable-features=VizDisplayCompositor --enable-blink-features=ViewTransition --remote-debugging-pipe

@yhatt
Copy link
Member

yhatt commented May 27, 2023

Yeah, the timeout has brought by not responding Chrome while Marp CLI is making connection with the browser via Puppeteer.

However, the latest (in-development) image is working PDF conversion correctly on Docker Engine 24.0.2 that was installed to Ubuntu 22.04. I've tested the AMD64 image with docker-ce installed to Ubuntu over WSL2.

$ docker pull marpteam/marp-cli
$ docker run --rm --init -v $PWD:/home/marp/app/ -e LANG=$LANG -e MARP_USER="$(id -u):$(id -g)" marpteam/marp-cli marp.md --pdf
[  INFO ] Converting 1 markdown...
[  INFO ] marp.md => marp.pdf

@rombert
Copy link

rombert commented May 30, 2023

@yhatt - that is good to know, thanks! For the record marpteam/marp-cli:latest@d61b099fe0a4 works just fine for me. I will keep using the 2.14.0 tag until there is a new one.

@yhatt yhatt closed this as completed Jun 11, 2023
@yhatt yhatt removed the help wanted Extra attention is needed label Jun 11, 2023
@yhatt yhatt unpinned this issue Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants