-
-
Notifications
You must be signed in to change notification settings - Fork 27
proxy keeps node process alive #29
Comments
hint: @yyjdelete suggested trying something like JoshGlazebrook/socks@c65706d as a patch. I wonder if that's really what it would take. And why it would work. There's an issue here that @TooTallNate's proxy projects seem to be... dead? So we may need to fork, or find something different. Perhaps it's a good idea to look into switching to https://npm.im/tunnel-agent? That's what |
Test snippet: const fetch = require('make-fetch-happen')
process.env.PROXY='http://icanhazip.com' // Without this line works fine
fetch('http://icanhazip.com').then(console.log).catch(console.error) |
Tried a simple attempt to catch object leaks. const fetch = require('make-fetch-happen')
const heapdump = require('heapdump')
const dump = () => new Promise((resolve,reject) => heapdump.writeSnapshot((err, filename) => {
if(err) reject(err);
resolve();
console.log('dump written to', filename)
}))
const test = () => fetch('http://icanhazip.com').then(console.log).catch(console.error)
test().then(dump).then(() => {
process.env.PROXY = 'http://icanhazip.com'
test().then(dump)
}); You can compare two heap dumps. Seems |
Come again? Is there a pull request I need to address? |
@TooTallNate oh! Great! Sorry, I saw that it'd been a few years since a release and didn't wanna bother you. I might end up having a pull request for you then -- just gotta figure out why using the proxies is keeping the node process alive 👍 |
Sounds great! Ya all my proxy modules have mostly been completed, hence the small amount of activity. But I'm here if you need help or find bugs. |
@TooTallNate do you have any idea where to look for why this particular bug is happening? It's definitely only when going through one of these proxies. |
If you can put together a simplified test case I can take a look. |
Will do! I'll push that onto the stack :) |
@zkat @TooTallNate And found there is already an PR for http as TooTallNate/node-socks-proxy-agent#12. |
I'm having a hard time coming up with a repro step isolated from npm itself :( I'll have to take a look at this much later, then, unless someone else picks it up. I've really no clue right now. |
Heads-up: The npm-side repro case is going away as of the latest beta 'cause I worked around the dangling socket issue (by calling |
@TooTallNate Thanx for your suggestion
|
@zkat @pi0 Sorry for the radio silence on this one. It's still on my radar I promise. I'm actually having trouble reproducing the issue locally, using a modified version of the example script in the README: const fetch = require('./').defaults({
cacheManager: './my-cache' // path where cache will be written (and read)
})
async function main() {
let res
let body
res = await fetch('https://registry.npmjs.org/make-fetch-happen')
console.log(res.status) // 200!
body = await res.json() // download the body as JSON
console.log(`got ${body.name} from web`)
res = await fetch('https://registry.npmjs.org/make-fetch-happen', {
cache: 'no-cache' // forces a conditional request
})
console.log(res.status) // 304! cache validated!
body = await res.json() // download the body as JSON
console.log(`got ${body.name} from cache`)
}
main().catch(console.error) When running with squid, works as expected:
Or with a SSH socks proxy setup to my iMac at home:
In both cases the process exits as expected (this is with Node 8.0.0). On a completely separate note, I notice that the
I think it would be really cool if m-f-h used that and we could move any necessary logic from your agent.js to |
@pi0 fwiw, this line in your repro sample is not correct: process.env.PROXY='http://icanhazip.com' // Without this line works fine icanhazip.com is not an HTTP proxy. It is the endpoint we are trying to connect to in this example. The |
@TooTallNate I was using As far as a repro: I, too, tried to find a minimal repro isolated even to m-f-h but failed to do so. I know the difference was between using a proxy and not, but I could only ever repro this on npm itself. It's really weird. It might have to do with number of requests, or size of requests, or something completely different that happens to be triggered by this. I've no idea. |
PAC being massive was because it was doing transpilation using But I'd also be interested in looking into making all the http proxy types be opt-in as |
oh great! I didn't like having to do this logic on m-f-h's end anyway. I'll make an issue to upgrade back to proxy-agent, then. |
sorry to revive an old topic and I apologize for any misunderstanding of how things work in advance. We recently hit this issue on our project due to being behind a proxy when doing our project install. I've tried to chase the issue down and it seems like the agent-base fix referenced here If you think it would help, I could try to do a pull request to bump the version of agent-base that is in package_lock? |
Credit: @TooTallNate Fixes: zkat/make-fetch-happen#29
@jjimenez npm/cli@6b70c02 I've bumped it in I have also published an npm canary, if you'd like to test to confirm this actually got fixed for you. You can try it using |
Credit: @TooTallNate Fixes: zkat/make-fetch-happen#29
Thanks @zkat I'll see about running a local test! |
There's an issue, probably with the proxy libraries make-fetch-happen is using, where the node process is kept alive if you use m-f-h's proxying agent features. This is likely because some socket somewhere isn't closing, or the libraries are doing some keepalive thing without any timeouts.
To set up a local SOCKS proxy to test with:
To set up a local http(s) proxy to test with:
You can use
PROXY={socks,http}://localhost:8888 node
to have make-fetch-happen pick it up. You should be able to hit any http or https service with m-f-h after that.The text was updated successfully, but these errors were encountered: