AWS Lambda copyObject "Process completed before request is completed"

I am trying to copy files uploaded to an S3 bucket to create temporary backups. (the "live" file will be rewritten periodically to maintain the perma link)

AWScopyObject, however, does not seem to be executing. I get the following error:

{ "errorMessage": "Process exited before completing request" } 

The code causing this error is as follows:

  console.log('Loading function'); var AWS = require('aws-sdk'); var s3 = new AWS.S3(); exports.handler = function(event, context) { var srcBucket = event.Records[0].s3.bucket.name; var srcKey = event.Records[0].s3.object.key; var dstKey = srcBucket+'/backup/'+ Date.now() + '-' +srcKey; console.log(srcKey); console.log(dstKey); var copyParams = { Bucket: srcBucket, CopySource : srcBucket + '/' + srcKey, Key: dstKey }; s3.copyObject( copyParams, function (err, data) { if (err) { console.log("ERROR copyObject"); console.log(err); } else { console.log('SUCCESS copyObject'); } context.done(); }); }; 

What can a lambda call to exit before an AWSCopyObject callback? According to https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/ this error assumes context.done () never gets caught.

+5
source share
1 answer

I ran into a similar problem, it looks like the problem I only got when I try to test using the AWS Lambda console, but when I tried to run a test with a real bucket (loaded a test file) and the Lambda function was successfully executed.

Try to see the "Log Out", you will get more detailed information about the actual error that you receive.

thanks

+5
source

All Articles