highchart-lambda-export-server icon indicating copy to clipboard operation
highchart-lambda-export-server copied to clipboard

Not running on Nodejs 12 or 14 (Error: write EPIPE)

Open ptrhck opened this issue 2 years ago • 0 comments

Nodejs 10 is not supported anymore at AWS Lambda. I used the following Docker Image to build the zip file and deployed it both, for Nodejs 12 and 14 and deployed to AWS Lambda.

FROM amazon/aws-lambda-nodejs:12

ARG HIGHCHARTS_VERSION=latest

ENV ENVIRONMENT=dev
ENV ACCEPT_HIGHCHARTS_LICENSE="YES"
ENV PHANTOMJS_PLATFORM="linux"
ENV PHANTOMJS_ARCH="x64"

# Install yarn and serverless
RUN npm install yarn -g
RUN yarn global add [email protected]

# Install required dependencies - without 'fontconfig' there will be errors in highcharts server
RUN yum install -y tar fontconfig yum-utils rpmdevtools libuuid-devel
WORKDIR /tmp
RUN yumdownloader fontconfig.x86_64 freetype.x86_64 expat.x86_64
RUN rpmdev-extract *.rpm

# Create the project and folders called lib and fonts inside it
RUN mkdir -p /highchart_export_server/lib
RUN mkdir -p /highchart_export_server/fonts

# Copy the installed dependencies to the lib folder
RUN cp /tmp/*/usr/lib64/* /highchart_export_server/lib

# Download the ttf fonts and unzip the fonts into the fonts dir
# Original source: https://github.com/tarkal/highchart-lambda-export-server/raw/master/resources/fonts.zip
ADD container_files/fonts /highchart_export_server/fonts

# Download the updated fonts.conf file and place it in the libs
# This seems to have no effect
# Original source: https://raw.githubusercontent.com/tarkal/highchart-lambda-export-server/master/src/lib/fonts.conf 
ADD container_files/fonts.conf /highchart_export_server/lib

# Init the project and install highcharts-export-server
WORKDIR /highchart_export_server
RUN npm install highcharts-export-server

# Download the basic index.js
# Original source: https://raw.githubusercontent.com/tarkal/highchart-lambda-export-server/master/src/index.js
ADD container_files/index.js /highchart_export_server/index.js

EXPOSE 8080
ENTRYPOINT ["/app/docker-entrypoint.sh"]
# Local development
CMD ["node_modules/.bin/highcharts-export-server", "--enableServer", "1", "--port", "8080"]

The following error occurs: `

Field Value
@message 2022-03-17T17:19:02.619Z 8b73cea3-4b09-41bb-9451-c1351dfacaed ERROR Uncaught Exception {"errorType":"Error","errorMessage":"write EPIPE","code":"EPIPE","errno":-32,"syscall":"write","stack":["Error: write EPIPE"," at afterWriteDispatched (internal/stream_base_commons.js:156:25)"," at writeGeneric (internal/stream_base_commons.js:147:3)"," at Socket._writeGeneric (net.js:798:11)"," at Socket._write (net.js:810:8)"," at writeOrBuffer (internal/streams/writable.js:358:12)"," at Socket.Writable.write (internal/streams/writable.js:303:10)"," at Object.worker.work (/var/task/node_modules/highcharts-export-server/lib/phantompool.js:264:34)"," at Object.postWork (/var/task/node_modules/highcharts-export-server/lib/phantompool.js:360:13)"," at exec (/var/task/node_modules/highcharts-export-server/lib/chart.js:176:11)"," at doExport (/var/task/node_modules/highcharts-export-server/lib/chart.js:228:5)"]}
@timestamp 1647537542619
code EPIPE
errno -32
errorMessage write EPIPE
errorType Error
stack.0 Error: write EPIPE
stack.1 at afterWriteDispatched (internal/stream_base_commons.js:156:25)
stack.2 at writeGeneric (internal/stream_base_commons.js:147:3)
stack.3 at Socket._writeGeneric (net.js:798:11)
stack.4 at Socket._write (net.js:810:8)
stack.5 at writeOrBuffer (internal/streams/writable.js:358:12)
stack.6 at Socket.Writable.write (internal/streams/writable.js:303:10)
stack.7 at Object.worker.work (/var/task/node_modules/highcharts-export-server/lib/phantompool.js:264:34)
stack.8 at Object.postWork (/var/task/node_modules/highcharts-export-server/lib/phantompool.js:360:13)
stack.9 at exec (/var/task/node_modules/highcharts-export-server/lib/chart.js:176:11)
stack.10 at doExport (/var/task/node_modules/highcharts-export-server/lib/chart.js:228:5)
syscall write
`

Anyone got it working on AWS Lambda Node 12 or 14?

ptrhck avatar Mar 17 '22 17:03 ptrhck