我正在尝试从aws lambda发布事件但是我收到以下错误:
Process exited before completing request
这是我的代码
exports.handler = (event, context, callback) => {
kinesis.PutRecord({
"Data": event,
"PartitionKey" : "1",
"StreamName": "TestStream"
});
context.done();
callback(null, "");
}
答案 0 :(得分:3)
您在context.done
函数之前调用了callback
,其中两个函数都是处理程序代码的退出回调函数。删除代码中的context.done
,并执行以下更改。
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
});
}