Skip to content

Lambda Runtime Error

0

Without making any changes, my Lambda function is now throwing this error. Can you please help resolve it?

{
  "errorType": "TypeError",
  "errorMessage": "Object.defineProperty called on non-object",
  "trace": [
    "TypeError: Object.defineProperty called on non-object",
    "    at defineProperty (<anonymous>)",
    "    at __name (/var/task/dist/index.js:83029:37)",
    "    at <static_initializer> (/var/task/dist/index.js:83221:9)",
    "    at node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js (/var/task/dist/index.js:83216:34)",
    "    at __require (/var/task/dist/index.js:13:51)",
    "    at node_modules/@aws-sdk/client-s3/dist-cjs/index.js (/var/task/dist/index.js:86346:37)",
    "    at __require (/var/task/dist/index.js:13:51)",
    "    at dist/src/lib/common_modules.js (/var/task/dist/index.js:96900:23)",
    "    at __require (/var/task/dist/index.js:13:51)",
    "    at dist/src/chargingSessions/queries.js (/var/task/dist/index.js:97202:28)"
  ]
}

asked 2 years ago417 views

2 Answers
1

The error you're experiencing is likely due to an unexpected runtime version update in your Lambda function. AWS Lambda automatically updates runtimes to the most recent and secure versions, which can sometimes lead to compatibility issues with existing functions.

To resolve this issue, you can try the following steps:

  1. Check if the error coincides with an automatic runtime update. You can do this by reviewing your function's logs or checking the runtime version history.

  2. Identify the last runtime version that your function successfully used. This information should be available in your function's configuration history.

  3. Use Lambda runtime management controls to manually update the runtime version used by your function. You can do this through the Lambda console or AWS CLI.

  4. If the issue persists, you may need to review and update your function code to ensure compatibility with the new runtime version. Pay special attention to the dependencies and layers used in your code, as they might need updating as well.

  5. If you need to revert to a previous working version, you can use the function ARN to roll back.

Remember, it's a best practice to keep your Lambda functions up-to-date with the latest runtime versions for security and performance reasons. However, you should also maintain a process for testing your functions with new runtime versions before they're automatically applied in production.

If you continue to face issues after trying these steps, you may need to reach out to AWS Support for further assistance, especially if you're using a runtime that's nearing or past its deprecation date.
Sources
Troubleshoot Lambda function runtime version errors | AWS re:Post
Upgrade Lambda function runtime to latest version | AWS re:Post
Managing AWS Lambda runtime upgrades | AWS Compute Blog

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Hello.

Is it possible for you to share the Lambda code where the error occurs?
Judging from the error message, it appears that a value that is not an object is being used for "Object.defineProperty".
I think it's difficult to troubleshoot without having the code that is causing the problem.

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • S3 version

    "@aws-sdk/client-s3": "^3.723.0", "@aws-sdk/s3-request-presigner": "^3.723.0",

    try{ const command = new PutObjectCommand(s3Params); const url = await getSignedUrl(s3, command, { expiresIn: 3600 }); // 3600 seconds = 1 hour return url; } catch (error) { throw new Error(Error: ${error.message}); }

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.