AWS Lambda函数从不调用callback

我创build了一个节点lambda函数,可以简单地调用Aurora数据库。 当我在控制台中testing函数时,查询返回,我可以在日志中看到结果,但callback似乎永远不会被调用,所以我的lambda函数超时。 我找不出什么问题。 希望这里有人能指点我这个问题。

var mysql = require("mysql"); module.exports.handler = function(event, context, cb) { console.log('start\n'); var con = mysql.createConnection({ ... }); console.log('call data\n'); con.query('SELECT * FROM Tags', function(err, rows) { console.log('Data received from Db:\n'); console.log(rows); console.log('calling callback'); cb(null, 'Success'); console.log('callback called'); }); console.log('data called\n'); }; 

由此产生的Cloudwatch日志如下所示…

 2016-07-25T14:20:05.343Z daf5cd6b-5272-11e6-9036-e73ad17006df start 2016-07-25T14:20:05.398Z daf5cd6b-5272-11e6-9036-e73ad17006df call data 2016-07-25T14:20:05.405Z daf5cd6b-5272-11e6-9036-e73ad17006df data called 2016-07-25T14:20:05.440Z daf5cd6b-5272-11e6-9036-e73ad17006df Data received from Db: 2016-07-25T14:20:05.440Z daf5cd6b-5272-11e6-9036-e73ad17006df [ RowDataPacket { id: 1, externalId: 'a87ead34de7e', orgId: 1, name: 'lacinia sapien', createdDate: 1448598369, modifiedDate: 0 }, ..., RowDataPacket { id: 50, externalId: '9ebaaab372e3', orgId: 1, name: 'et commodo', createdDate: 1451551837, modifiedDate: 0 } ] 2016-07-25T14:20:05.483Z daf5cd6b-5272-11e6-9036-e73ad17006df calling callback 2016-07-25T14:20:05.483Z daf5cd6b-5272-11e6-9036-e73ad17006df callback called END RequestId: daf5cd6b-5272-11e6-9036-e73ad17006df REPORT RequestId: daf5cd6b-5272-11e6-9036-e73ad17006df Duration: 300000.12 ms Billed Duration: 300000 ms Memory Size: 1024 MB Max Memory Used: 52 MB 2016-07-25T14:25:05.341Z daf5cd6b-5272-11e6-9036-e73ad17006df Task timed out after 300.00 seconds 

       

网上收集的解决方案 "AWS Lambda函数从不调用callback"