1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Catch errors when invoking applyPath2DToCanvasRenderingContext

This way we allow the rest of the packages to be loaded successfully, such that e.g. the Node.js unit-tests work correctly.

Note that this occurred after updating the `node-canvas` package to version `3.0.0-rc2`, however it's not immediately clear to me if it's a problem there or in the `path2d` package; see also nilzona/path2d-polyfill/issues/84.
This commit is contained in:
Jonas Jenwald 2024-10-19 17:21:54 +02:00
parent 6ae13fac9b
commit 54e00b0104

View file

@ -83,7 +83,11 @@ if (isNodeJS) {
applyPath2DToCanvasRenderingContext &&
Path2D
) {
applyPath2DToCanvasRenderingContext(CanvasRenderingContext2D);
try {
applyPath2DToCanvasRenderingContext(CanvasRenderingContext2D);
} catch (ex) {
warn(`applyPath2DToCanvasRenderingContext: "${ex}".`);
}
globalThis.Path2D = Path2D;
} else {
warn("Cannot polyfill `Path2D`, rendering may be broken.");