question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Catch puppeteer errors not possible?

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
krylovaaleksandracommented, Apr 7, 2022

+1

1reaction
krylovaaleksandracommented, Apr 9, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I capture browser errors? · Issue #1030 · puppeteer ...
How do I capture browser errors? When using puppeteer for automated testing, if the page is wrongly reported due to a JavaScript error, ......
Read more >
Try Catch unable to catch UnhandledPromiseRejectionWarning
I need it to "TRYAGAIN" in case it fails for what ever reason. Now it just stops with the error and does nothing....
Read more >
Basic Error Handling - Puppeteer NodeJS p.5 - YouTube
How to do basic error handling with Puppeteer. ... ?list=PLRmEk9smitaXljDN2CjwZ96o4Aj87iuC5# Puppeteer # Error #Hand... ... Get __it Done!
Read more >
Puppeteer: Better Project Setup - Return String
We can use .catch to make sure we handle every error an async function will throw, even if we do not await the...
Read more >
Puppeteer documentation - DevDocs
Puppeteer methods might throw errors if they are unable to fulfill a request. For example, page.waitForSelector(selector[, options]) might fail if the selector ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found