s3.getObject().promise() never returns anything

Solution 1:

const data = (await (s3.getObject(params).promise())).Body.toString('utf-8')

Solution 2:

If your Lambda function is associated with a VPC it loses internet access which is required to access S3. However, instead of following the Lambda warning that says "Associate a NAT" etc, you can create an S3 endpoint in the VPC > Endpoints settings, and your Lambda function will work as expected, with no need to manually set up Internet access for your VPC.

https://aws.amazon.com/blogs/aws/new-vpc-endpoint-for-amazon-s3/

Solution 3:

This issue is definitely related to connection.

Check out your VPC settings as it is likely blocking the Lambda connection to the Internet (AWS managed services as S3 are accessible only via Internet).

Solution 4:

Default timeout of AWS SDK is 120000 ms. If your lambda's timeout is shorter then that, you will never receive the actual error.

Either extend your AWS timeout

var AWS = require('aws-sdk');
var s3 = new AWS.S3({httpOptions: {timeout: 3000}});

or extend the timout of your lambda.