我一直在使用 html-pdf (phantomjs) 在 AWS Lambda 上使用 NodeJS 8.0 创建 PDF,它运行良好。由于 AWS Lambda 已停止对 NodeJS 8.0 的支持,我们已将 NodeJS 版本更新到最新的 12.x,当我们用完 PDF Lambda 函数时出现以下错误:
{"errorType":"Error","errorMessage":"write EPIPE","code":"EPIPE","errno":"EPIPE","syscall":"write","stack":["Error: write EPIPE"," at afterWriteDispatched (internal/stream_base_commons.js:154:25)"," at writeGeneric (internal/stream_base_commons.js:145:3)"," at Socket._writeGeneric (net.js:784:11)"," at Socket._write (net.js:796:8)"," at doWrite (_stream_writable.js:403:12)"," at writeOrBuffer (_stream_writable.js:387:5)"," at Socket.Writable.write (_stream_writable.js:318:11)"," at PDF.PdfExec [as exec] (/var/task/node_modules/html-pdf/lib/pdf.js:141:15)"," at PDF.PdfToBuffer [as toBuffer] (/var/task/node_modules/html-pdf/lib/pdf.js:44:8)"," at /var/task/index.js:121:38"]}
phantomPath: './phantomjs_lambda/phantomjs'
process.env.FONTCONFIG_PATH='/var/task/fonts'
我试图检查 StackOverflow 中的类似问题。我已经正确地指出了 phantomjs 路径,也有适当的 fontconfig。我们现在卡住了,因为我们无法更新 Lambda 函数。任何帮助将不胜感激。
更新:更改了 phantomjs 二进制文件的路径:
phantomPath: './node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs'
将路径更改为phantomjs二进制后,错误已更改为:
{"errorType":"Error","errorMessage":"write EPIPE","code":"EPIPE","errno":"EPIPE","syscall":"write","stack":["Error: write EPIPE"," at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:92:16)"]}