Severless Lambda Function Rendering PowerBi pdf

0

I have a serverless (v4) node (v20.x) lambda function. The function creates a headless chromium browser using puppeteer, loads html content from PowerBi, modifies the content and generates a pdf. Pupppeteer and chromium are at the latest versions. Chromium is being loaded from a lambda layer. The lambda function is called by a lambda url.

The application works exactly as expected when run locally (Windows 11 OS). The content of the pdf is exactly as I expect it to be.

When I run the function on AWS, the pdf is generated but there is no content except for the boiler plate information.

In the puppeteer configuration, I set dumpio to true to get a verbose log of the process. That log shows the message: ERROR: font_unique_name_lookup_linux.cc(21)] @font-face src: local() instantiation only available when connected to browser process.

The error is logged throughout the pdf generation process as the pdf is re-rendered multiple times.

When I run locally, I do not get this error.

I have tried various options to define an online font source for the html. I have recently tried a font config file but so far that has not worked.

Any help would be greatly appreciated.

corey
asked 2 months ago52 views
2 Answers
0

It's unclear what you are trying to accomplish by loading Chromium in AWS Lambda. The Puppeteer library may be assuming the code is running on a full operating system that it can access. However, since the code is running in a Lambda function, this may not be the case, potentially leading to the error you're experiencing.

Without more details about your specific use case and implementation, it's difficult to determine the root cause of the issue conclusively. More information about what you're attempting to achieve and the steps you've taken so far would be helpful in diagnosing the problem and suggesting a solution.

Please provide additional context about your project, the specific error you're encountering, and the steps you've taken so far. With more details, I can better assess the situation and offer more targeted guidance.

profile pictureAWS
answered 2 months ago
0

@hsoni-from-aws This application is based on a lambda function developed by a co-worker last year which used a similar approach. The limitations of power bi required that the html code be loaded into a headless browser so it could be manipulated before generating a pdf. The lambda function created by my co-worker works as expected but uses serverless v3, node 18x, and a slightly older version of puppeteer.

The specific error I am getting is: ERROR: font_unique_name_lookup_linux.cc(21)] @font-face src: local() instantiation only available when connected to browser process.

I have consulted message forums and co-pilot. I have tried using the features of puppeteer to define a font to use. I enabled the dumpio flag, so I could compare the debug output from running on aws vs. running locally. I have started exploring using a fontconfig file and uploading fonts as a part of my package. All of the changes I have tried have not had an effect on the error message I am seeing.

corey
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions