AWS lambda function gets crash and throws below error. But working fine in my local environment

0

Hi There,

I have using the Serverless application for my Node Application. I have my specific serverless.yml file and i used layers concept to pack my dependency.

I have my all basic modules code in serverHandler Lambda function. That function contains many HTTP calls(API gateway), Like wise i have implemented the jsreport tool in my application.

I have implemented the jsreport logic with necessary package and logic in my Class object and exported properly and i have used that object function in my one of end point (/invoice-generate) this is comes under the serverHandler lambda.

When i try run my application in my local that perfectly working and jsreport provides the proper Output.

Problem is When i deploy the code on aws lambda my whole app gets crash and throws below error:

This error captured in CloudWatch.

**ERROR Uncaught Exception { "errorType": "TypeError", "errorMessage": "Cannot read properties of undefined (reading 'filename')", "stack": [ "TypeError: Cannot read properties of undefined (reading 'filename')", " at resolve (/var/task/dist/index.js:394335:50)", " at module2.exports (/var/task/dist/index.js:394352:25)", " at node_modules/app-root-path/index.js (/var/task/dist/index.js:394379:23)", " at __require (/var/task/dist/index.js:13:50)", " at node_modules/jsreport-core/lib/reporter.js (/var/task/dist/index.js:394634:19)", " at __require (/var/task/dist/index.js:13:50)", " at node_modules/jsreport-core/index.js (/var/task/dist/index.js:398812:20)", " at __require (/var/task/dist/index.js:13:50)", " at dist/src/lib/download_service.js (/var/task/dist/index.js:573617:20)", " at __require (/var/task/dist/index.js:13:50)", " at dist/src/chargingSessions/invoices.js (/var/task/dist/index.js:573710:30)", " at __require (/var/task/dist/index.js:13:50)", " at dist/src/chargingSessions/router.js (/var/task/dist/index.js:573848:22)", " at __require (/var/task/dist/index.js:13:50)", " at dist/src/setupRoute.js (/var/task/dist/index.js:621827:21)", " at __require (/var/task/dist/index.js:13:50)", " at Object. (/var/task/dist/index.js:622691:20)", " at Module._compile (node:internal/modules/cjs/loader:1198:14)", " at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)", " at Module.load (node:internal/modules/cjs/loader:1076:32)", " at Function.Module._load (node:internal/modules/cjs/loader:911:12)", " at Module.require (node:internal/modules/cjs/loader:1100:19)" ] **

Even i have download the lambda function from s3, There is no line available which is given by the cloud watch logs. Im not sure what is the root cause of this. I have tried for last 5 days to find out the root cause. But i could not. Im confusing why not working in AWS lambda but working in my machine.

Folks/techees Please help me to get this things sort out. Im in a situation that i need to fix this ASAP. Please let me know if you need more details about my Code structure. Im happy to share the details.

Jay
asked 9 months ago361 views
2 Answers
0

The error message seems to indicate that you're trying to read a property called (or of) filename which is not present. Without the source code (even a small extract of it) it's quite difficult to determine what the problem is. It would also help to know what the invocation payload is for Lambda (you can find this in the event object that is passed to the Lambda handler - output that using console.log() or your favourite logging tool.

profile pictureAWS
EXPERT
answered 9 months ago
0

In general the exception/error shared by you, is a code error and 'Undefined' means that a variable has been declared/initialised but has not been assigned a value. I would kindly recommend you to add some error handling and input validation in your code to analyse and debug such errors.

You can also refer to this document provided below, to know more about the TypeError: [+] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError

If you have any additional queries/concerns then kindly open a case with the support team and they will be able to assist you.

AWS
answered 9 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