Skip to content

Commit 203fdc6

Browse files
test
1 parent 673e7ac commit 203fdc6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/mongoPatch.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ interface Config {
88
/** The journey apps cc egress proxy domain */
99
proxy: string;
1010
}
11+
12+
const originalCreateConnection = socks.SocksClient.createConnection;
13+
1114
/**
1215
* The patch should be called before instantiating the MongoClient
1316
* @param config - The configuration for the proxy
@@ -30,12 +33,16 @@ export function useProxyForMongo(config: Config) {
3033
sockets.map(
3134
(socket) =>
3235
new Promise<void>((resolve) => {
33-
socket.once('close', resolve);
36+
socket.once('close', ()=>{
37+
console.log('Socket closed');
38+
resolve();
39+
});
3440
socket.destroy();
3541
}),
3642
),
3743
);
3844
sockets.length = 0;
45+
socks.SocksClient.createConnection = originalCreateConnection;
3946
},
4047
};
4148
}

0 commit comments

Comments
 (0)