I am trying to publish events from aws lambda but I get the following error:
Process exited before completing request
Here's my code
exports.handler = (event, context, callback) => {
kinesis.PutRecord({
"Data": event,
"PartitionKey" : "1",
"StreamName": "TestStream"
});
context.done();
callback(null, "");
}
You have context.done
called before the callback
function where both are exit callbacks for the handler code. Remove context.done
in your code, and also do the following change.
const AWS = require('aws-sdk');
const kinesis = new AWS.Kinesis({apiVersion: '2013-12-02'});
exports.handler = (event, context, callback) => {
kinesis.putRecord({
"Data": event,
"PartitionKey" : "1",
"StreamName": "TestStream"
},
function(err, data) {
if (err)
console.log(err, err.stack); // an error occurred
else
callback(null, data); // successful response
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.