simonhaenisch / md-to-pdf

Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
https://www.npmjs.com/md-to-pdf
MIT License
1.14k stars 110 forks source link

'Bash wrote one or more lines to the standard error stream' on Azure Pipelines #198

Closed aaronparker closed 1 year ago

aaronparker commented 1 year ago

Context:

Describe the bug:

Running md-to-pdf on an Azure Pipeline with the following command results in the error in the debug log below:

cat "./prod-as-built.md" | md-to-pdf --config-file "./md2pdf/htmlconfig.json" --as-html > "./prod-as-built.html"

The pipeline with no modifications has been running OK up until about a week ago. The same command run locally on macOS with Node.js 20.0.0 runs OK. I'm not 100% certain this is actually an md-to-pdf issue - I have tested with md-to-pdf 5.2.3, 5.2.2. and 5.2.1.

I will try with the Pipeline configured to not fail on this step and see whether the HTML is still produced.

2023-05-04T09:41:18.7636143Z ##[debug]Evaluating condition for step: 'Convert markdown to HTML'
2023-05-04T09:41:18.7636779Z ##[debug]Evaluating: SucceededNode()
2023-05-04T09:41:18.7636982Z ##[debug]Evaluating SucceededNode:
2023-05-04T09:41:18.7637290Z ##[debug]=> True
2023-05-04T09:41:18.7637501Z ##[debug]Result: True
2023-05-04T09:41:18.7637724Z ##[section]Starting: Convert markdown to HTML
2023-05-04T09:41:18.7641751Z ==============================================================================
2023-05-04T09:41:18.7641855Z Task         : Bash
2023-05-04T09:41:18.7641902Z Description  : Run a Bash script on macOS, Linux, or Windows
2023-05-04T09:41:18.7641978Z Version      : 3.214.0
2023-05-04T09:41:18.7642044Z Author       : Microsoft Corporation
2023-05-04T09:41:18.7642108Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
2023-05-04T09:41:18.7642346Z ==============================================================================
2023-05-04T09:41:18.8008036Z ##[debug]Using node path: /home/vsts/agents/3.220.0/externals/node16/bin/node
2023-05-04T09:41:18.8867152Z ##[debug]agent.TempDirectory=/home/vsts/work/_temp
2023-05-04T09:41:18.8881205Z ##[debug]loading inputs and endpoints
2023-05-04T09:41:18.8887725Z ##[debug]loading INPUT_TARGETTYPE
2023-05-04T09:41:18.8901133Z ##[debug]loading INPUT_FILEPATH
2023-05-04T09:41:18.8905094Z ##[debug]loading INPUT_SCRIPT
2023-05-04T09:41:18.8908547Z ##[debug]loading INPUT_WORKINGDIRECTORY
2023-05-04T09:41:18.8911877Z ##[debug]loading INPUT_FAILONSTDERR
2023-05-04T09:41:18.8916061Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2023-05-04T09:41:18.8916810Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2023-05-04T09:41:18.8919089Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2023-05-04T09:41:18.8922579Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2023-05-04T09:41:18.8924866Z ##[debug]loading SECRET_CLIENT_SECRET
2023-05-04T09:41:18.8927098Z ##[debug]loaded 10
2023-05-04T09:41:18.8930571Z ##[debug]Agent.ProxyUrl=undefined
2023-05-04T09:41:18.8931120Z ##[debug]Agent.CAInfo=undefined
2023-05-04T09:41:18.8931862Z ##[debug]Agent.ClientCert=undefined
2023-05-04T09:41:18.8932412Z ##[debug]Agent.SkipCertValidation=undefined
2023-05-04T09:41:18.8937137Z ##[debug]check path : /home/vsts/work/_tasks/Bash_6c731c3c-3c68-459a-a5c9-bde6e6595b5b/3.214.0/task.json
2023-05-04T09:41:18.8939863Z ##[debug]adding resource file: /home/vsts/work/_tasks/Bash_6c731c3c-3c68-459a-a5c9-bde6e6595b5b/3.214.0/task.json
2023-05-04T09:41:18.8940474Z ##[debug]system.culture=en-US
2023-05-04T09:41:18.8950747Z ##[debug]failOnStderr=true
2023-05-04T09:41:18.8953360Z ##[debug]workingDirectory=/home/vsts/work/1/s
2023-05-04T09:41:18.8953910Z ##[debug]check path : /home/vsts/work/1/s
2023-05-04T09:41:18.8955771Z ##[debug]targetType=inline
2023-05-04T09:41:18.8956328Z ##[debug]bashEnvValue=undefined
2023-05-04T09:41:18.8957196Z ##[debug]script=cat "/home/vsts/work/1/s/prod-as-built.md" | md-to-pdf --config-file "/home/vsts/work/1/s/md2pdf/htmlconfig.json" --as-html > "/home/vsts/work/1/s/prod-as-built.html"
2023-05-04T09:41:18.8966938Z Generating script.
2023-05-04T09:41:18.8969410Z ##[debug]which 'bash'
2023-05-04T09:41:18.8979308Z ##[debug]found: '/usr/bin/bash'
2023-05-04T09:41:18.8979667Z Script contents:
2023-05-04T09:41:18.8980575Z cat "/home/vsts/work/1/s/prod-as-built.md" | md-to-pdf --config-file "/home/vsts/work/1/s/md2pdf/htmlconfig.json" --as-html > "/home/vsts/work/1/s/prod-as-built.html"
2023-05-04T09:41:18.8981090Z ##[debug]Agent.Version=3.220.0
2023-05-04T09:41:18.8981751Z ##[debug]agent.tempDirectory=/home/vsts/work/_temp
2023-05-04T09:41:18.8982228Z ##[debug]check path : /home/vsts/work/_temp
2023-05-04T09:41:18.8989617Z ========================== Starting Command Output ===========================
2023-05-04T09:41:18.8991058Z ##[debug]which '/usr/bin/bash'
2023-05-04T09:41:18.8992170Z ##[debug]found: '/usr/bin/bash'
2023-05-04T09:41:18.8992666Z ##[debug]/usr/bin/bash arg: /home/vsts/work/_temp/e1c5efbe-fa89-4c72-af59-9507e596d583.sh
2023-05-04T09:41:18.8996059Z ##[debug]exec tool: /usr/bin/bash
2023-05-04T09:41:18.8996527Z ##[debug]arguments:
2023-05-04T09:41:18.8997197Z ##[debug]   /home/vsts/work/_temp/e1c5efbe-fa89-4c72-af59-9507e596d583.sh
2023-05-04T09:41:18.8998807Z [command]/usr/bin/bash /home/vsts/work/_temp/e1c5efbe-fa89-4c72-af59-9507e596d583.sh
2023-05-04T09:41:21.0993723Z 
2023-05-04T09:41:21.0996709Z   Puppeteer old Headless deprecation warning:
2023-05-04T09:41:21.0996890Z     In the near feature `headless: true` will default to the new Headless mode
2023-05-04T09:41:21.0997098Z     for Chrome instead of the old Headless implementation. For more
2023-05-04T09:41:21.0999682Z     information, please see https://developer.chrome.com/articles/new-headless/.
2023-05-04T09:41:21.1001289Z     Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
2023-05-04T09:41:21.1002070Z     If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.
2023-05-04T09:41:21.1002407Z 
2023-05-04T09:41:27.4651277Z ##[debug]Exit code 0 received from tool '/usr/bin/bash'
2023-05-04T09:41:27.4654117Z ##[debug]STDIO streams have closed for tool '/usr/bin/bash'
2023-05-04T09:41:27.4691781Z ##[error]Bash wrote one or more lines to the standard error stream.
2023-05-04T09:41:27.4698378Z ##[debug]Processed: ##vso[task.issue type=error;]Bash wrote one or more lines to the standard error stream.
2023-05-04T09:41:27.4699676Z ##[error]
  Puppeteer old Headless deprecation warning:
    In the near feature `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

2023-05-04T09:41:27.4700616Z ##[debug]Processed: ##vso[task.issue type=error;]
  Puppeteer old Headless deprecation warning:
    In the near feature `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

2023-05-04T09:41:27.4701219Z ##[debug]task result: Failed
2023-05-04T09:41:27.4702749Z ##[debug]Processed: ##vso[task.complete result=Failed;done=true;]
2023-05-04T09:41:27.4721458Z ##[section]Finishing: Convert markdown to HTML
simonhaenisch commented 1 year ago

You can see in the logs that the exit code is 0 so your pipeline should not fail just because something was written to stderr (some puppeteer deprecation warning in this case). I would guess this is most likely a problem with your pipeline configuration.

simonhaenisch commented 1 year ago

Looking at this question on SO: https://stackoverflow.com/questions/58621159/azure-command-line-task-what-is-the-difference-between-fail-on-standard-error

Most likely you have ticked this "fail on standard error" checkbox in your task.

aaronparker commented 1 year ago

🤦‍♂️ Ah, of course! Thank-you