getndazn / dazn-lambda-powertools

Powertools (logger, HTTP client, AWS clients, middlewares, patterns) for Lambda functions.
https://getndazn.github.io/dazn-lambda-powertools
MIT License
740 stars 77 forks source link

wrap() never returns, causing timeout #239

Open kpeters-cbsi opened 4 years ago

kpeters-cbsi commented 4 years ago

This is a Bug Report

Description

Similar or dependent issues:

Additional Data

Note that this only seems to happen in Lambdas using mysql2/promise

shawnm0705 commented 3 years ago

It's probably because you have something that is still up which doesn't end the event loop (e.g. database connection) try to use https://www.npmjs.com/package/@middy/do-not-wait-for-empty-event-loop and set it to something like this:

const doNotWaitForEmptyEventLoop = require('@middy/do-not-wait-for-empty-event-loop');

exports.handler = wrap(serverless(app)).use(doNotWaitForEmptyEventLoop({
  runOnBefore: true,
  runOnAfter: true,
  runOnError: true,
}));
kpeters-cbsi commented 3 years ago

Thanks, I'll try that!

On Mon, Jan 11, 2021 at 10:09 PM Shawn Ma notifications@github.com wrote:

It's probably because you have something that is still up which doesn't end the event loop (e.g. database connection) try to use https://www.npmjs.com/package/@middy/do-not-wait-for-empty-event-loop and set it to something like this: const doNotWaitForEmptyEventLoop = require('@middy/do-not-wait-for-empty-event-loop'); exports.handler = wrap(serverless(app)).use(doNotWaitForEmptyEventLoop({ runOnBefore: true, runOnAfter: true, runOnError: true, })); — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .