proxy-chain 3.0.1-beta.3 → 3.0.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/forward.js CHANGED
@@ -88,6 +88,16 @@ export const forward = async (request, response, handlerOpts) => new Promise(asy
88
88
  });
89
89
  // Can't use pipeline here as it automatically destroys the streams
90
90
  request.pipe(client);
91
+ // Mirrors chain.ts: if the client-facing side goes away before the
92
+ // upstream request/response completes (e.g. server.close(true) during
93
+ // shutdown, or the client disconnecting early), destroy the outbound
94
+ // request/socket too, so it isn't left dangling indefinitely.
95
+ // This runs before the byte-counting `close` handler registered above
96
+ // (it's added later, asynchronously, once a socket exists) - that's fine,
97
+ // since destroy() doesn't affect the already-recorded bytesRead/bytesWritten.
98
+ response.on('close', () => {
99
+ client.destroy();
100
+ });
91
101
  client.on('error', (error) => {
92
102
  if (response.headersSent) {
93
103
  resolve();
@@ -54,6 +54,13 @@ export const forwardSocks = async (request, response, handlerOpts) => new Promis
54
54
  });
55
55
  // Can't use pipeline here as it automatically destroys the streams
56
56
  request.pipe(client);
57
+ // Mirrors chain.ts: if the client-facing side goes away before the
58
+ // upstream request/response completes (e.g. server.close(true) during
59
+ // shutdown, or the client disconnecting early), destroy the outbound
60
+ // request/socket too, so it isn't left dangling indefinitely.
61
+ response.on('close', () => {
62
+ client.destroy();
63
+ });
57
64
  client.on('error', (error) => {
58
65
  if (response.headersSent) {
59
66
  resolve();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proxy-chain",
3
- "version": "3.0.1-beta.3",
3
+ "version": "3.0.1-beta.4",
4
4
  "description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",