Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap() never returns, causing timeout #239

Open
kpeters-cbsi opened this issue Nov 18, 2020 · 2 comments
Open

wrap() never returns, causing timeout #239

kpeters-cbsi opened this issue Nov 18, 2020 · 2 comments

Comments

@kpeters-cbsi
Copy link

This is a Bug Report

Description

  • What went wrong? Lambda handler using wrap() does not return, causing function to time out
  • What did you expect should have happened? handler should have returned
  • What was the config (if any) you used? None
  • What stacktrace or error message did you see? Request timed out

Similar or dependent issues:

  • N/A

Additional Data

  • Which powertool package are you using?: lambda-powertools-pattern-basic
  • Which version are you using?: 1.27.0
  • Middy engine version you're using: 1.4.0
  • Operating System: AWS Lambda / NodeJS
  • Stack Trace: N/A
  • Provider Error messages: N/A

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

@shawnm0705
Copy link

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
Copy link
Author

kpeters-cbsi commented Jan 12, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants