node-html-to-image
node-html-to-image copied to clipboard
Catch puppeteer errors not possible?
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) => { .... }
+1
Hello @rielzzapps 👋
Thank you for opening this issue 🙏 Can you share the content of the html variable so I can reproduce your issue, please?
< 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 <)
+1 please look into this issue
+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
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 😄
Without any new answer I close this issue. Feels free to reopen it with full reproductible example 👍