question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting errors using this package in AWS Lambda Nodejs 10.x and up

See original GitHub issue

I’ve been using this package for ages and worked like a charm on AWS Lambda with Nodejs 8.10 and older.

But AWS now forces you to use 10.x and later…

When I updated my version I started getting the following errors from the lambda execution stack:

ERROR	Uncaught Exception	
{
    "errorType": "Error",
    "errorMessage": "write EPIPE",
    "code": "EPIPE",
    "errno": "EPIPE",
    "syscall": "write",
    "stack": [
        "Error: write EPIPE",
        "    at WriteWrap.afterWrite [as oncomplete] (net.js:789:14)"
    ]
}

It also throws this error just before the above error:

Error: html-pdf: Received the exit code '127'
/var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

    at ChildProcess.respond (/var/task/node_modules/html-pdf/lib/pdf.js:121:31)
    at ChildProcess.emit (events.js:198:13)
    at ChildProcess.EventEmitter.emit (domain.js:448:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)

I have tried setting the phantomPath option, still did not help.

Any help will be greatly appreciated.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:24

github_iconTop GitHub Comments

7reactions
jeff-shepcommented, Jan 27, 2020

Two other resources got this fixed for me on Node 10:

For more context and a guide if you want to compile everything yourself: https://stackoverflow.com/questions/56795567/how-do-you-install-phantomjs-on-aws-lambda

Or get the output in this repo: https://github.com/naeemshaikh27/phantom-lambda-fontconfig-pack

As a minimum to get it working:

  • Copy all the .so files and put them in your project root
  • Copy the fonts.conf file and put in fonts directory
  • Add Lambda Environment Variable “FONTCONFIG_PATH” with value equal to fonts directory (so “/var/task/{FONTS_DIR}”)

NOTE: LD_LIBRARY_PATH was not required for it to work

3reactions
anilpandey199905commented, Sep 26, 2020

I am also facing the same issue on Microsoft azure app server “error”: { “status”: 500, “message”: “html-pdf: Received the exit code ‘127’\n/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory\n” }

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Lambda function errors in Node.js
This page describes how to view Lambda function invocation errors for the Node.js runtime using the Lambda console and the AWS CLI.
Read more >
NPM package `pem` doesn't seem to work in AWS lambda ...
I tried the answer documented by @Kris White, but I was not able to get it to work. Each execution resulted in the...
Read more >
Upgrading to Serverless Framework v3
The default Lambda runtime has changed from NodeJS 12 to NodeJS 14, given this is now the default runtime recommended by AWS. Additionally,...
Read more >
Reviewing the AWS Lambda nodejs10.x runtime - Michael Hart
As with the other runtimes, it patches the native console.(log|error|warn|info) functions to prepend tab-separated metadata to each call (not a huge fan of ......
Read more >
Cannot find module (AWS Lambda Error) [Solved] | bobbyhadz
A complete step-by-step guide on how to solve the "Cannot find module" error when trying to load third party packages in AWS lambda....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found