Intermittent nodejs runtime errors when including PaperJS

37 views
Skip to first unread message

Ben Feist

unread,
Mar 7, 2022, 2:07:31 PM3/7/22
to Paper.js
Hi all,
I've written an app using React/Next.js. This means the code is isomorphic (it is run first by Node at build time, and then in the browser at run time).

Intermittently, when running the application for the first time after deployment, I get the following Node error. This error persists until the Node server is stopped and started again, sometimes requireing restart several times. Eventually, the application runs without error.

It appears that Node is trying to get a context from a canvas object in relation to Paper.js. I don't understand why this would work intermittently. Regardless, does anyone have any advice on how to get Paper.js to not need a canvas object when instanciated within Node?

root@environment:/usr/home/env> journalctl -xe -u app
Mar 07 11:27:41 username npm[1243]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
Mar 07 11:27:41 username npm[1243]: at Module.require (internal/modules/cjs/loader.js:974:19)
Mar 07 11:27:41 username npm[1243]: at require (internal/modules/cjs/helpers.js:101:18)
Mar 07 11:27:41 username npm[1243]: at Object.389 (/opt/fitbox/apps/app/.next/server/pages/view/nbl.js:660:38)
Mar 07 11:27:41 username npm[1243]: at __webpack_require__ (/opt/fitbox/apps/app/.next/server/webpack-runtime.js:25:42) undefined
Mar 07 11:27:41 username npm[1243]: Error: Canvas [object HTMLCanvasElement] is unable to provide a 2D context.
Mar 07 11:27:41 username npm[1243]: at Object.getCanvas (/opt/fitbox/apps/app/node_modules/paper/dist/paper-full.js:14348:10)
Mar 07 11:27:41 username npm[1243]: at Object.getContext (/opt/fitbox/apps/app/node_modules/paper/dist/paper-full.js:14363:21)
Mar 07 11:27:41 username npm[1243]: at new <anonymous> (/opt/fitbox/apps/app/node_modules/paper/dist/paper-full.js:14562:27)
Mar 07 11:27:41 username npm[1243]: at Object.<anonymous> (/opt/fitbox/apps/app/node_modules/paper/dist/paper-full.js:14376:17)
Mar 07 11:27:41 username npm[1243]: at Object.<anonymous> (/opt/fitbox/apps/app/node_modules/paper/dist/paper-full.js:17459:3)
Mar 07 11:27:41 username npm[1243]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
Mar 07 11:27:41 username npm[1243]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
Mar 07 11:27:41 username npm[1243]: at Module.load (internal/modules/cjs/loader.js:950:32)
Mar 07 11:27:41 username npm[1243]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
Mar 07 11:27:41 username npm[1243]: at Module.require (internal/modules/cjs/loader.js:974:19)
Mar 07 11:27:41 username npm[1243]: at require (internal/modules/cjs/helpers.js:101:18)
Mar 07 11:27:41 username npm[1243]: at Object.389 (/opt/fitbox/apps/app/.next/server/pages/view/nbl.js:660:38)
Mar 07 11:27:41 username npm[1243]: at __webpack_require__ (/opt/fitbox/apps/app/.next/server/webpack-runtime.js:25:42)
Mar 07 11:27:41 username npm[1243]: at Object.7755 (/opt/fitbox/apps/app/.next/server/pages/view/nbl.js:6866:73)
Mar 07 11:27:41 username npm[1243]: at __webpack_require__ (/opt/fitbox/apps/app/.next/server/webpack-runtime.js:25:42)
Mar 07 11:27:41 username npm[1243]: at __webpack_exec__ (/opt/fitbox/apps/app/.next/server/pages/view/nbl.js:10081:52)
Mar 07 11:33:59 username systemd[1]: Stopping app node application...

Juro Dobrik

unread,
Mar 7, 2022, 2:18:20 PM3/7/22
to pap...@googlegroups.com
React problem....

--
You received this message because you are subscribed to the Google Groups "Paper.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/paperjs/e152cb2a-5710-4d90-aa43-6d43a3df5927n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages