-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Lambda always timeouts for both async or callback handler with middy (returned response is swallowed) #567
Comments
Ok, I've checked some other similar issues for Middy (since I don't know about the ecosystem and started using it 2 days ago) and seems like But it still seems Also, why is Cheers |
Update! Works locally and when deployed to AWS export default middy(handler)
.use(inputOutputLogger())
.use(doNotWaitForEmptyEventLoop({ runOnError: true , runOnBefore: true, runOnAfter: true }))
.use(httpSecurityHeaders())
.use(httpEventNormalizer()) Adding secrets-manager middleware works only locally! (watching the logs the request doesn't even reach the main handler) export default middy(handler)
.use(inputOutputLogger())
.use(doNotWaitForEmptyEventLoop({ runOnError: true , runOnBefore: true, runOnAfter: true }))
.use(httpSecurityHeaders())
.use(httpEventNormalizer())
.use(
secretsManager({
secrets: {
mySectet: process.env.MY_SECRET
}
})
) |
Glad to see you found a solution to your issue. Sorry that our documentation was clear enough. If you'd like to add in some additional documentation around Per Secrets Manager, are you able to create a unit test that fails? |
Hello @willfarrell Thanks for the reply, totally forgot about the issue here. For the However, if you have some misconfiguration like for example providing the wrong name for a parameter that cannot be found on SSM the middleware won't throw the error (rather it is not handled anywhere) and the function hangs until it timeouts! Take look at
Regarding the Regards, |
Thanks, that's good to know. Would you be interested in writing a PR to catch where this timeout occurs? |
@willfarrell opened PR #572 |
What are the steps to reproduce this issue?
Running the function below locally with serverless framework (serverless-offline) works as expected but when deployed to AWS it always timeouts. I was using the secret manager and custom db-manager middleware and it was ok but only locally (suspected they were the reason for the timeouts but turns out not the case, the same outcome once removed too).
I've tried switching to callback handler but still the same outcome, the return response object is swallowed and the lambda goes to timeout.
Also tried to return Promise.resolve(...), no luck
All the methods work perfectly ok locally.
What happens?
The lambda function always goes to timeout
What were you expecting to happen?
Return success or error response
Any logs, error output, etc?
No errors, all the console logs up to the return statement are correctly displayed in the CloudWatch log but the function remains stuck until it goes to timeout.
Any other comments?
p.s tomorrow I'll try to switch to CommonJS modules and try without webpack bundling
What versions of software are you using?
Node.js Version:
Middy Version: => 1.4.0
AWS SDK Version: => 2.767.0
The text was updated successfully, but these errors were encountered: