Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda Cryptic Node.js error: Unknown application error occurred

I recently updated my lambda Node.js runtime from 8.x to 12.x. I upgraded lots of dependencies and optimized the bundling with webpack and the deployment process. BUT, I started to notice sporadic errors in Cloudwatch with a cryptic message "Unknown application error occurred" with no stack trace or any other log that could give me some context about the function input. There is no way for me to debug this code, and it appears to be a native AWS error that cannot even invoke the function for some reason, otherwise, there would be a JS stack trace attached to the log...

I'm starting to think there is a Webpack issue, but I even disabled the minification process so I have no clue where to look.

My code is 100% Typescript compiled using Webpack & Babel. Should I try removing Webpack from the build process and just zip the Typescript compiler output with the plain node_modules folder and no bundling whatsoever?

Can someone please help me? This function is in production!

EDIT: I see a bunch of warnings like DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead., and I am aware of, but it should not be the cause of this cryptic error.

like image 484
demian85 Avatar asked Jan 27 '20 13:01

demian85


1 Answers

I've recently had this error but my error happened every other request. First request I get a good response, the second (same) request, I get the error "Unknown application error occurred".

I was using NodeJS mysql2 module and was not closing the pool connection properly after each request which forced the second request to fail, then NodeJS resets and the following request is good again.

like image 191
Paul M Avatar answered Sep 18 '22 16:09

Paul M