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

Scripts not exiting #310

Closed
mhart opened this issue Jun 25, 2014 · 8 comments
Closed

Scripts not exiting #310

mhart opened this issue Jun 25, 2014 · 8 comments

Comments

@mhart
Copy link
Contributor

mhart commented Jun 25, 2014

The following script prints done but doesn't exit. On aws-sdk 2.0.3 and node v0.10.29:

var AWS = require('aws-sdk')
var ec2 = new AWS.EC2

ec2.describeInstances(function() {
  console.log('done')
})

Perhaps there's something still being held by the event loop?

This may also be related to #307?

@lsegal lsegal added the Bug label Jun 25, 2014
@lsegal
Copy link
Contributor

lsegal commented Jun 25, 2014

This is not related to #307. This is related to the use of the new keepalive agent being used by the SDK to improve latency when sending many requests to a service. It looks like this agent is keeping the connection alive indefinitely. I'm investigating if there is an issue with the library of if it is just being misused. You can workaround this issue by reverting back to the global agent for now:

AWS.config.httpOptions = {agent: require('https').globalAgent};

@mhart
Copy link
Contributor Author

mhart commented Jun 25, 2014

Using agentkeepalive as described on its README seems to work fine (ie, the example exits ok) - but I guess there may be issues with more advanced usage...?

@mhart
Copy link
Contributor Author

mhart commented Jun 25, 2014

Hmmm, I didn't try https though

@lsegal
Copy link
Contributor

lsegal commented Jun 25, 2014

Using the httpOptions.agent parameter should be equivalent to using it in the context of a low-level https.request call. All we do is pass that agent object through to the options if one was provided (if one was not, we provide a default): https://github.com/aws/aws-sdk-js/blob/master/lib/http/node.js#L35-L39

In other words, if you passed an agentkeepalive Agent.HttpsAgent() in, it should be equivalent to the example. Something else must be going on that causes the hang, but it is somehow related to this library.

@mhart
Copy link
Contributor Author

mhart commented Jun 25, 2014

Just tried, their https example works fine too... Not sure what's going on!

@lsegal
Copy link
Contributor

lsegal commented Jun 25, 2014

It has to do with timeout behavior on the socket. Adding req.setTimeout(0); prior to req.end() in the agentkeepalive examples reproduces the behavior. The issue is that agentkeepalive seems to rely on timeout behavior and the SDK is resetting this timeout behavior. I'm going to keep investigating to see if there's any way I can make this work transparently, but I'm thinking that we may have to pull agentkeepalive out until we can figure out a better way to get this behavior working.

lsegal added a commit that referenced this issue Jun 25, 2014
This reverts commit 214fedf.

This module needs more investigation before it can be re-introduced
into the SDK since it causes various "hang" and socket leak issues
(see below).

Fixes #297, #310
@lsegal
Copy link
Contributor

lsegal commented Jun 26, 2014

I've reverted agentkeepalive for the time being until we can figure out a less intrusive way to add keepalive behavior. This should be out in the next release.

@lsegal lsegal closed this as completed Jun 26, 2014
lsegal added a commit that referenced this issue Jun 26, 2014
@lock
Copy link

lock bot commented Sep 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants