You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to ctx.drawImage an invalid image, the entire process gets instantly/silently crashed, with no error.
The expectation is to throw an error that we can catch.
const{ writeFileSync }=require('fs');asyncfunctiontest(canvasCtor,loadImage,name){try{console.log(`Starting to test ${name}`)constcanvas=newcanvasCtor(100,100);constimage=awaitloadImage(('./badimage.png'));constctx=canvas.getContext('2d');ctx.drawImage(image,0,0);writeFileSync(`./${name}.png`,canvas.toBuffer());}catch(e){console.error(`${name} failed with: ${e}`)}console.log(`Finished testing ${name}`);}setInterval(()=>{// Keep the event loop awake until we manually CTRL+C},10_000);asyncfunctionmain(){awaittest(require("canvas").Canvas,require("canvas").loadImage,"node-canvas")awaittest(require("skia-canvas").Canvas,require("skia-canvas").loadImage,"skia-canvas");awaittest(require("@napi-rs/canvas").Canvas,require("@napi-rs/canvas").loadImage,"@napi-rs/canvas");}main();
$ node ./
Starting to test node-canvas
node-canvas failed with: Error: Unsupported image type
Finished testing node-canvas
Starting to test skia-canvas
skia-canvas failed with: Error: Missing Source URL
Finished testing skia-canvas
[Process crashes here]
canvas and skia-canvas both handle it by throwing an error, napi-canvas will crash entirely. Here's a script to reproduce it.
The text was updated successfully, but these errors were encountered:
When trying to
ctx.drawImage
an invalid image, the entire process gets instantly/silently crashed, with no error.The expectation is to throw an error that we can catch.
canvas
andskia-canvas
both handle it by throwing an error, napi-canvas will crash entirely. Here's a script to reproduce it.The text was updated successfully, but these errors were encountered: