Skip to content

Catch puppeteer errors not possible? #165

Open
@rielzzapps

Description

@rielzzapps

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) => { .... } 

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions