AWS Lambda Error: Quit inactivity timeout at Quit

Ani*_*aje 1 mysql amazon-web-services node.js npm aws-lambda

I am facing a strange issue on AWS Lambda in which my API calls fail with a 502 error,
I checked the CloudWatch logs, and in these cases, not even my 1st line of code which is logging the event object is getting printed
The function call is not reaching the DAO layer of my code for sure.

The logs are showing the following trace -

2019-07-25T08:03:55.668Z    2329a426-a841-4ce2-91ed-1000c623ba14    Error: Quit inactivity timeout
at Quit.<anonymous> (/opt/layer/node_modules/mysql/lib/protocol/Protocol.js:160:17)
at emitNone (events.js:106:13)
at Quit.emit (events.js:208:7)
at Quit._onTimeout (/opt/layer/node_modules/mysql/lib/protocol/sequences/Sequence.js:124:8)
at Timer._onTimeout (/opt/layer/node_modules/mysql/lib/protocol/Timer.js:32:23)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)
Run Code Online (Sandbox Code Playgroud)

Here's a log sample of this strange request -
在此输入图像描述

I this API behavior is inconsistent,
These failure calls don't even print the first line of my handler
I am using node 8.10 and mysql lib "mysql": "^2.17.1"

小智 5

你好吗?

我面临着同样的问题,我解决了它非常简单:

我改变了connection.end(); 通过connectionn.destroy();

destroy 在执行其功能后,立即终止与 DB 的连接。“结束”是异步的,这可能是错误的原因。

看:

“要强制立即关闭连接,可以使用 destroy() 方法。destroy() 方法保证不会再为连接触发任何回调或事件。请注意,destroy() 方法不接受任何回调参数,例如end() 方法。”

字体: https: //www.mysqltutorial.org/mysql-nodejs/connect/