When connecting to MySQL from Node.js on AWS Lambda, “Quit inactivity timeout” appears.

Haruyuki Mohri
2 min readJan 1, 2021

When connecting to MySQL from Node.js on AWS Lambda, “Quit inactivity timeout” occasionally appears.In my case, this phenomenon has a 1/50 chance of getting an error.The module for MySQL connection that I used was installed as follows.

npm install mysql

The content of the error was as follows.

2020-12-31T09:53:06.051Z XXXX-XXXX-XXXX-XXXX-XXXX ERROR Uncaught Exception  {
"errorType": "Error",
"errorMessage": "Quit inactivity timeout",
"code": "PROTOCOL_SEQUENCE_TIMEOUT",
"fatal": true,
"timeout": 30000,
"stack": [
"Error: Quit inactivity timeout",
" at Quit.<anonymous> (/var/task/node_modules/mysql/lib/protocol/Protocol.js:160:17)",
" at Quit.emit (events.js:314:20)",
" at Quit._onTimeout (/var/task/node_modules/mysql/lib/protocol/sequences/Sequence.js:124:8)",
" at Timer._onTimeout (/var/task/node_modules/mysql/lib/protocol/Timer.js:32:23)",
" at listOnTimeout (internal/timers.js:554:17)",
" at processTimers (internal/timers.js:497:7)"
]
}

I wrote “Quit inactivity timeout”, so I thought it was the end() function.So, I wrapped the end function processing with Promise function.By wrapping it with the Promise function, the error has disappeared so far.

--

--