math-api
math-api copied to clipboard
Lambda runtimes from nodejs10.x onwards break PNG conversion
using as runtime node from version 10 (since nodejs8.10
cannot be used anymore) trying converting to PNG produces the following error:
{
"errorType": "Error",
"errorMessage": "write EPIPE",
"code": "EPIPE",
"errno": "EPIPE",
"syscall": "write",
"stack": [
"Error: write EPIPE",
" at afterWriteDispatched (internal/stream_base_commons.js:156:25)",
" at writevGeneric (internal/stream_base_commons.js:139:3)",
" at Socket._writeGeneric (net.js:785:11)",
" at Socket._writev (net.js:794:8)",
" at doWrite (_stream_writable.js:401:12)",
" at clearBuffer (_stream_writable.js:519:5)",
" at Socket.Writable.uncork (_stream_writable.js:338:7)",
" at Socket.Writable.end (_stream_writable.js:590:10)",
" at Socket.end (net.js:591:31)",
" at writeBufferInChunks (/opt/nodejs/node_modules/svg2png/lib/svg2png.js:54:20)"
]
}
This seems to be a problem linked with PhantomJS (dependency of svg2png
), which can no longer be used directly in the Lambda environment as some system dependencies have been removed from the newer runtimes (eg. fontconfig
)
In order to fix the problem an extra layer could be created to add the missing libs ( https://github.com/naeemshaikh27/phantom-lambda-fontconfig-pack ) or maybe the function body could be defined as container image
Hi @MRoci, thanks for reporting this issue.
I'll take a look as soon as possible. Rather than using layers, I'd probably opt to refactor this project to use containers in Lambda functions. Hopefully it's easier to maintain and doesn't require duplicate package.json
: it wasn't possible when we first started this project, so we had to stick with Layers.