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

Random timeout while invoking long running lambda (cont.) #3762

Closed
3 tasks done
michaeltarleton opened this issue May 11, 2021 · 4 comments
Closed
3 tasks done

Random timeout while invoking long running lambda (cont.) #3762

michaeltarleton opened this issue May 11, 2021 · 4 comments
Assignees
Labels
bug This issue is a bug.

Comments

@michaeltarleton
Copy link

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
Hi,

We are having this random timeout problem in our amazon Lambda that runs a node script that in turn uses aws-sdk (2.706.0) to invoke another lambda which takes ~6min.

Our lambda 1 will randomly timeout after 15 mins (900s) despite the lambda 2 having a log saying it ran successfully:

So looks like Lambda 2 completes successfully but Lambda 1 never gets the response (only if Lambda 2 takes ~6 mins or longer).

(seems to be related to #2558)

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?

Details of the browser/Node.js version
Node 12_x (using cloudformation through CDK)

SDK version number
Example: v2.706.0

To Reproduce (observed behavior)

  1. Create Lambda 1 that calls a Lambda 2
  2. Create a 6 minute delay in Lambda 2, then respond w/ success
  3. Run Lambda 1 (with timeout set to 15 mins)

Expected behavior

Lambda 1 should get the success response from Lambda 2.

Additional context

We have tried:

  • adding keepAlive: true
  • increasing timeouts
@michaeltarleton michaeltarleton added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 11, 2021
@vudh1 vudh1 added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 9, 2021
@vudh1
Copy link
Contributor

vudh1 commented Dec 9, 2021

Hi @michaeltarleton thanks for reaching out. Are you still experiencing this with the latest version of the SDK?

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Dec 10, 2021
@michaeltarleton
Copy link
Author

I have since changed companies but at the time I left this was still an issue.

@vudh1
Copy link
Contributor

vudh1 commented Dec 10, 2021

Feel free to reopen this issue if the problem is still persisting with the latest version of SDK.

@vudh1 vudh1 closed this as completed Dec 10, 2021
@bbright024
Copy link

turns out it's a problem with node itself, not the aws sdk.
nodejs/node#47137

@michaeltarleton and all others impacted by this bug -

there's a simple hack you can use to avoid this issue: complete a guaranteed fast request with the client, before attempting the >5 minute request.

e.g. if there's a lambda invoke that may take >5 minutes, first use the client to make an invoke request with the DryRun parameter set to true, then attempt the >5 minute invoke.

DryRun – Validate parameter values and verify that the user or role has permission to invoke the function.
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html

this works because the keepalive parameters are not applied until after the first request is completed. you can see it in this code -

state.keepAliveTimeoutSet = true;

I highly recommend adding this workaround to your code - bnoordhuis mentions that this is intended behavior in node, so there's no guarantee it will ever be fixed:

The keepAliveMsecs option isn't applied until the socket is added to the connection pool, i.e., after the first request. That's by design, as far as I'm aware.
(2) is a policy change. Best way forward is to open a pull request and see how it's received.
nodejs/node#47137 (comment)

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

No branches or pull requests

3 participants