dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.16k stars 794 forks source link

Module did not self register with Canvas Node in Serverless offline v12 #1706

Closed alexluongfm closed 1 year ago

alexluongfm commented 1 year ago

Bug Report

This is mainly to make this issue easy to google, and cross link with the canvas node not supporting worker_threads ticket. Similar to sharp module not registering issue.

Current Behavior After running a handler, that invokes node-canvas once, the second and subsequent invocations gives a module did not self-register error. This gets fixed if I restart serverless offline

ANY /api/generate-canvas (λ: api)
✖ Unhandled exception in handler 'api'.
✖ Error: Module did not self-register: '/dev/serverless/node_modules/canvas/build/Release/canvas.node'.

Environment

Possible Solution

Worker threads not supported in canvas, need to switch to inProcess. This does mean hot reloading handlers doesn't work anymore, unfortunate.

Run serverless offline with the flag: --useInProcess. Eg serverless offline start --useInProcess