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...