Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Catch puppeteer errors not possible? #165

Open
rielzzapps opened this issue Mar 21, 2022 · 7 comments
Open

Catch puppeteer errors not possible? #165

rielzzapps opened this issue Mar 21, 2022 · 7 comments

Comments

@rielzzapps
Copy link

rielzzapps commented Mar 21, 2022

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) => { .... } 
@krylovaaleksandra
Copy link

+1

@frinyvonnick
Copy link
Owner

Hello @rielzzapps 👋

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

@krylovaaleksandra
Copy link

< 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 <)

@silhouette5366
Copy link

+1
please look into this issue

@NaN-NaN-sempai
Copy link

+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

@frinyvonnick
Copy link
Owner

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
Copy link
Owner

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

5 participants