marp-team / marp-cli

A CLI interface for Marp and Marpit based converters
MIT License
1.92k stars 108 forks source link

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

Closed hofbi closed 1 year ago

hofbi commented 1 year ago

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

cyril-marpaud commented 1 year ago

Same error in Gitlab-CI since this morning.

image

This used to work just fine last week.

hofbi commented 1 year ago

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

yhatt commented 1 year ago

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:

spkane commented 1 year ago

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.

[ 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 commented 1 year ago

In case this proves useful:

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 commented 1 year ago

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 commented 1 year ago

@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.