Skip to content

Commit f3f5d69

Browse files
test
1 parent 079f28e commit f3f5d69

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/mongoPatch.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ interface Config {
1414
*/
1515
export function useProxyForMongo(config: Config) {
1616
const sockets: tls.TLSSocket[] = [];
17+
const proxy = new HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
1718
socks.SocksClient.createConnection = async (options, callback) => {
18-
const proxy = new HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
1919
const socket = await proxy.connect({ host: options.destination.host, port: options.destination.port });
2020
sockets.push(socket);
2121
return {
@@ -27,10 +27,7 @@ export function useProxyForMongo(config: Config) {
2727
console.log(`Closing ${sockets.length} open proxy sockets`);
2828
for (const socket of sockets) {
2929
await new Promise((resolve, reject) => {
30-
socket.on('close', () => {
31-
socket.destroy();
32-
resolve(socket);
33-
});
30+
socket.on('close', () => resolve);
3431
socket.end();
3532
});
3633
}

0 commit comments

Comments
 (0)