Skip to content

Commit 98ca849

Browse files
single proxy
1 parent f95c3a4 commit 98ca849

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/HttpsProxySocket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class HttpsProxySocket {
149149
// nullify the buffered data since we won't be needing it
150150
buffers = [];
151151

152-
// cleanup();
152+
cleanup();
153153
cb(null, sock);
154154
} else {
155155
// some other status code that's not 200... need to re-play the HTTP header

src/mongoPatch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ interface Config {
1515
*/
1616
export function useProxyForMongo(config: Config) {
1717
const sockets: tls.TLSSocket[] = [];
18+
let proxy: HttpsProxySocket | undefined = new HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
1819
socks.SocksClient.createConnection = async (options, callback) => {
19-
const proxy = new HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
20-
const socket = await proxy.connect({ host: options.destination.host, port: options.destination.port });
20+
const socket = await proxy!.connect({ host: options.destination.host, port: options.destination.port });
2121
sockets.push(socket);
2222
return {
2323
socket,
@@ -38,6 +38,7 @@ export function useProxyForMongo(config: Config) {
3838
}),
3939
),
4040
);
41+
proxy = undefined;
4142
if (count === sockets.length) {
4243
console.log(`Closed ${sockets.length} MongoDB connection sockets`);
4344
}

0 commit comments

Comments
 (0)