2017-07-28 94 views
1

我試圖發佈從AWS拉姆達事件,但我得到以下錯誤:出版退出

Process exited before completing request 

這裏是我的代碼

exports.handler = (event, context, callback) => { 
    kinesis.PutRecord({ 
    "Data": event, 
    "PartitionKey" : "1", 
    "StreamName": "TestStream" 
    }); 
    context.done(); 
    callback(null, ""); 
} 

回答

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 
    }); 
} 
+0

即使沒有context.done我仍然得到同樣的錯誤 –

+0

問題是室壁運動不拉姆達 –

+0

定義我已經更新了答案 – Ashan