node-html-to-image icon indicating copy to clipboard operation
node-html-to-image copied to clipboard

Catch puppeteer errors not possible?

Open rielzzapps opened this issue 2 years ago • 7 comments

The parser / puppeteer crashes with an error: 'Uncaught Error: Parse error on line 25:' This might be malformed HTML, but I want to catch this error, to handle it and present the user a message.

(html is a string with html content here, that gets an image preview)

It seems like I am unable to catch a puppeteer error, not in a try/catch loop, nor in a .catch promise. Any ideas?

    const image = await nodeHtmlToImage({
    puppeteerArgs: {
      args: [
        "--disable-gpu",
        "--disable-dev-shm-usage",
        "--disable-setuid-sandbox",
        "--no-sandbox"
    ]},
    html:  `<style>
    body {
      width: 420px;
      height: 100px;
      padding: 15px;
    }
  </style>${html}`
   
  }).catch(async (e: any) => { .... } 

rielzzapps avatar Mar 21 '22 15:03 rielzzapps

+1

krylovaaleksandra avatar Apr 07 '22 22:04 krylovaaleksandra

Hello @rielzzapps 👋

Thank you for opening this issue 🙏 Can you share the content of the html variable so I can reproduce your issue, please?

frinyvonnick avatar Apr 08 '22 07:04 frinyvonnick

< video id="video_background" preload="auto" autoplay="true" loop="true" muted="muted" class="video-9--6_I"> < source src="https://cdn.discordapp.com/attachments/880449376957390941/889581462108639263/pososi_mudila.webm" type="video/webm" /> < /video>

(remove spaces after <)

krylovaaleksandra avatar Apr 09 '22 19:04 krylovaaleksandra

+1 please look into this issue

silhouette5366 avatar Oct 03 '22 11:10 silhouette5366

+1 There really should be a way to catch erros from the html, a lot of things cause it to break my script, like not giving a html value or giveing a empty string

NaN-NaN-sempai avatar Nov 15 '22 00:11 NaN-NaN-sempai

I'm maintaining this repository on my free time. If someone want to investigate on this it would be appreciated otherwise I'll give it a look when I have time to do it. The link @krylovaaleksandra provided does not seems to work 🤔 I would prefer to have a full reproductible example. The more you provide the easier it is to fix the issue 😄

frinyvonnick avatar Nov 15 '22 11:11 frinyvonnick

Without any new answer I close this issue. Feels free to reopen it with full reproductible example 👍

frinyvonnick avatar Aug 05 '23 09:08 frinyvonnick