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

ProxyToServer connection timeout is not handled #287

Open
fopinappb opened this issue Apr 11, 2023 · 1 comment
Open

ProxyToServer connection timeout is not handled #287

fopinappb opened this issue Apr 11, 2023 · 1 comment

Comments

@fopinappb
Copy link

fopinappb commented Apr 11, 2023

Recently I bumped into the issue where my library (that uses this) was hanging after termination.

Debugging showed event loop was filled with TLSWrap and socket calls which led me to connection timeouts and to these lines:

ctx.proxyToServerRequest.on(
"error",
self._onError.bind(self, "PROXY_TO_SERVER_REQUEST_ERROR", ctx)
);

error event does not include timeout, so even after clients give up and close connection (ClientToProxy), these were left hanging.

Google led me to https://stackoverflow.com/a/55021202 and I've added

   ctx.proxyToServerRequest.on("error", self._onError.bind(self, "PROXY_TO_SERVER_REQUEST_ERROR", ctx));
+ ctx.proxyToServerRequest.on("timeout", () => {ctx.proxyToServerRequest.destroy()});

The destroy() is now triggering on timeout and then triggering the previously set error handler.

I haven't opened a PR with this as I'm not sure of its impact, leaving this up as an issue 😄

Calling destroy() on the http agents also destroys all open sockets and properly allows termination.

Currently doing this when calling Proxy.close()

@RikaShiro
Copy link

same issue here
error

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