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

PDFs don't compile in zenika Docker #611

Closed
pdessus opened this issue Oct 9, 2024 · 7 comments · Fixed by #614
Closed

PDFs don't compile in zenika Docker #611

pdessus opened this issue Oct 9, 2024 · 7 comments · Fixed by #614

Comments

@pdessus
Copy link

pdessus commented Oct 9, 2024

We use a docker zenika/alpine-chrome:with-node to compile slides with Marp (URL: https://gricad-gitlab.univ-grenoble-alpes.fr/inspe-sciedu/slides). We got this error message below;
thx for fixing this!
best,
phd
node:events:497
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at Pipe.onStreamRead (node:internal/stream_base_commons:218:20)
Emitted 'error' event on Socket instance at:
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read'
}
Node.js v20.15.1

@yhatt
Copy link
Member

yhatt commented Oct 9, 2024

It seems that you are trying to use the prior major version of Marp CLI v3.4.0. The latest Chromium may be incompatible with old CLI versions due to the migration into the new headless mode. Try the latest CLI version v4.0.0.

@danielef
Copy link

danielef commented Oct 28, 2024

I'm experiencing the same problem. Previously, I was using version 3.4.0 with the node:20-bookworm Docker image and the default Chromium without any issues:

$ apt-get update && apt-get install -y chromium
$ export CHROME_PATH=/usr/bin/chromium
$ marp --allow-local-files --theme-set themes/my.css --html src/my.md -o build/my.pdf
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from
          src/my.md.
node:events:497
      throw er; // Unhandled 'error' event
      ^
Error: read ECONNRESET
    at Pipe.onStreamRead (node:internal/stream_base_commons:218:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}
Node.js v20.18.0

@yhatt
Copy link
Member

yhatt commented Oct 28, 2024

If you are using Marp CLI v4.0.0, please try enabling full debug logs to help identify where the bug is occurring. Add --debug=all option to CLI options.
https://github.com/marp-team/marp-cli/blob/main/.github/CONTRIBUTING.md#debug

@danielef
Copy link

This is the output enabling full debug:

$ marp --debug=all --allow-local-files --theme-set themes/my.css --html src/my.md -o build/my.pdf
2024-10-28T17:22:05.954Z portfinder:defaultHosts exports._defaultHosts is: [ '0.0.0.0', '127.0.0.1', '::1', '172.17.0.2', null ]
[  INFO ] Debug logging is enabled. (Filter pattern: *)
2024-10-28T17:22:06.225Z marp-cli:browser Browser manager configured: { finders: undefined, path: undefined, protocol: 'cdp', timeout: undefined }
[  INFO ] Converting 1 markdown...
2024-10-28T17:22:06.240Z marp-cli:browser:finder Start finding browser from chrome, edge, firefox ({ preferredPath: undefined })
2024-10-28T17:22:06.243Z marp-cli:browser:finder Found chrome: { path: '/usr/bin/chromium', acceptedBrowsers: [ [class nn extends Bt] { kind: 'chrome', protocol: 'webDriverBiDi' }, [class rn extends nn] { protocol: 'cdp' } ] }
2024-10-28T17:22:06.243Z marp-cli:browser:finder Use browser: { path: '/usr/bin/chromium', acceptedBrowsers: [ [class nn extends Bt] { kind: 'chrome', protocol: 'webDriverBiDi' }, [class rn extends nn] { protocol: 'cdp' } ] }
2024-10-28T17:22:06.244Z marp-cli:browser Use browser class for conversion: [class rn extends nn] { protocol: 'cdp' }
[  WARN ] Insecure local file accessing is enabled for conversion from
          src/my.md.
2024-10-28T17:22:06.526Z marp-cli CLIError: Edge browser could not be found.
    at fe (/builds/mygrp/mypdf/node_modules/@marp-team/marp-cli/lib/marp-cli-XhAyCP9_.js:1:8125)
    at edge (/builds/mygrp/mypdf/node_modules/@marp-team/marp-cli/lib/marp-cli-XhAyCP9_.js:18:56911) {
  errorCode: 2
}
2024-10-28T17:22:06.531Z marp-cli Saving temporary file: /root/tmp-3110-SMljKSypfj28-.html
2024-10-28T17:22:06.531Z marp-cli Saving file: /root/tmp-3110-SMljKSypfj28-.html
2024-10-28T17:22:06.535Z marp-cli Saved: /root/tmp-3110-SMljKSypfj28-.html
2024-10-28T17:22:06.539Z marp-cli:browser Chrome data directory: /tmp/marp-cli-wrPtZvNDaT
2024-10-28T17:22:06.540Z marp-cli CLIError: Firefox browser could not be found.
    at fe (/builds/mygrp/mypdf/node_modules/@marp-team/marp-cli/lib/marp-cli-XhAyCP9_.js:1:8125)
    at firefox (/builds/mygrp/mypdf/node_modules/@marp-team/marp-cli/lib/marp-cli-XhAyCP9_.js:18:58377) {
  errorCode: 2
}
2024-10-28T17:22:06.540Z marp-cli:browser Created data directory: /tmp/marp-cli-wrPtZvNDaT
2024-10-28T17:22:06.542Z puppeteer:browsers:launcher Launching /usr/bin/chromium --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-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,IsolateSandboxedIframes --enable-features=PdfOopif --headless=new --hide-scrollbars --mute-audio about:blank --user-data-dir=/tmp/marp-cli-wrPtZvNDaT --test-type --remote-debugging-pipe {
  detached: true,
  env: {},
  stdio: [ 'ignore', 'ignore', 'ignore', 'pipe', 'pipe' ]
}
2024-10-28T17:22:06.544Z puppeteer:browsers:launcher Launched 3122
2024-10-28T17:22:06.547Z puppeteer:protocol:SEND ► [
  '{"method":"Target.setDiscoverTargets","params":{"discover":true,"filter":[{}]},"id":1}'
]
2024-10-28T17:22:06.601Z puppeteer:browsers:launcher Trying to kill 3122
2024-10-28T17:22:06.601Z puppeteer:browsers:launcher Browser process 3122 exists
node:events:497
      throw er; // Unhandled 'error' event
      ^
Error: read ECONNRESET
    at Pipe.onStreamRead (node:internal/stream_base_commons:218:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read'
}
Node.js v20.18.0

Thanks!

@yhatt
Copy link
Member

yhatt commented Oct 28, 2024

A possible cause is crashing Chromium process immidiately due to trying to launch the browser as the root user without disabling Chromium sandbox.

Can you launch Chromium to check the version by /usr/bin/chromium -v? If cannot like a below, try to disable Chrome/Chromium sandbox while running Marp CLI by setting CHROME_NO_SANDBOX environment value as 1.

# chromium -v
[3448:3448:1028/175626.061413:ERROR:zygote_host_impl_linux.cc(101)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

@danielef
Copy link

That worked like a charm! Thanks a ton for your help!

$ apt-get update && apt-get install -y chromium
$ export CHROME_PATH=/usr/bin/chromium
$ export CHROME_NO_SANDBOX=1
$ marp --allow-local-files --theme-set themes/my.css --html src/my.md -o build/my.pdf
[  INFO ] Converting 1 markdown...
[  WARN ] Insecure local file accessing is enabled for conversion from
          src/my.md.
[  INFO ] src/my.md => build/my.pdf

@yhatt
Copy link
Member

yhatt commented Oct 31, 2024

This case has been fixed in Marp CLI v4.0.2.

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

Successfully merging a pull request may close this issue.

3 participants