Skip to content

Commit

Permalink
Catch errors when invoking applyPath2DToCanvasRenderingContext
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Snuffleupagus committed Oct 19, 2024
1 parent c07f4aa commit 78243c8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/display/node_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit 78243c8

Please sign in to comment.