我試圖使用Fastcsv nodejs包轉換CSV文件。有趣的是,代碼片段在我的系統上很好地工作。但是,如果我嘗試將它與AWS lambda程序集成,它會在寫入錯誤後提供寫入。AWS Lambda中的流轉換導致寫入錯誤
var stream = fs.createReadStream(s3EventInfo.inputDownloadLoc)
.pipe(csv.parse({headers: true}))
//pipe the parsed input into a csv formatter
.pipe(csv.format({headers: true}))
//Using the transfrom function from the formatting stream
.transform(function(row, next){
transformLine(row, next);
})
.pipe(fs.createWriteStream(s3EventInfo.outputFileLoc))
.on("end", function(){
callback();
});
這裏是AWS日誌中的錯誤..
Error: write after end
at writeAfterEnd (_stream_writable.js:133:12)
at PassThrough.Writable.write (_stream_writable.js:181:5)
at write (_stream_readable.js:602:24)
at flow (_stream_readable.js:611:7)
at _stream_readable.js:579:7
at process._tickDomainCallback (node.js:486:13)
在理解和解決問題請幫助。