Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
940fa05
WIP: track multiple sockets for mongo driver's connection pool
johnshearar Jan 23, 2026
992b6c8
nvmrc file in ci
EspressoTrip-v2 Jan 24, 2026
ede8f21
git workflows
EspressoTrip-v2 Jan 27, 2026
94c3c5e
version bump
EspressoTrip-v2 Jan 27, 2026
1513c91
branch
EspressoTrip-v2 Jan 27, 2026
07c3e46
workflow
EspressoTrip-v2 Jan 27, 2026
43406ba
workflow
EspressoTrip-v2 Jan 27, 2026
2884d8c
workflow
EspressoTrip-v2 Jan 27, 2026
c1cee88
workflow
EspressoTrip-v2 Jan 27, 2026
ace8ee1
Check soccket length
EspressoTrip-v2 Jan 27, 2026
7eb36d5
test
EspressoTrip-v2 Jan 27, 2026
2ab9a42
destroy socket
EspressoTrip-v2 Jan 27, 2026
bc164d3
urgh
EspressoTrip-v2 Jan 27, 2026
45349d6
test
EspressoTrip-v2 Jan 27, 2026
c9ac7af
test
EspressoTrip-v2 Jan 27, 2026
079f28e
test
EspressoTrip-v2 Jan 27, 2026
f3f5d69
test
EspressoTrip-v2 Jan 27, 2026
0c57f74
test
EspressoTrip-v2 Jan 27, 2026
e655ab6
test
EspressoTrip-v2 Jan 27, 2026
9900087
test
EspressoTrip-v2 Jan 27, 2026
4491c9b
test
EspressoTrip-v2 Jan 27, 2026
dfab84d
test
EspressoTrip-v2 Jan 27, 2026
10bfe59
test
EspressoTrip-v2 Jan 27, 2026
673e7ac
test
EspressoTrip-v2 Jan 27, 2026
203fdc6
test
EspressoTrip-v2 Jan 27, 2026
0d5adce
test exit
EspressoTrip-v2 Jan 27, 2026
a826e0c
sockets
EspressoTrip-v2 Jan 27, 2026
69f7da7
destroy socket
EspressoTrip-v2 Jan 27, 2026
6d67c91
revert
EspressoTrip-v2 Jan 27, 2026
ca68c61
trying to find the hang
EspressoTrip-v2 Jan 27, 2026
f95c3a4
removed cleanup
EspressoTrip-v2 Jan 27, 2026
98ca849
single proxy
EspressoTrip-v2 Jan 27, 2026
6c9481a
test
EspressoTrip-v2 Jan 27, 2026
540db42
destroy with error
EspressoTrip-v2 Jan 27, 2026
7ede132
socket status
EspressoTrip-v2 Jan 28, 2026
b119392
logs
EspressoTrip-v2 Jan 28, 2026
249d707
testing
EspressoTrip-v2 Jan 28, 2026
4d8420a
refactor
EspressoTrip-v2 Jan 28, 2026
50e138e
test
EspressoTrip-v2 Jan 28, 2026
d3b0e04
destroy existing socket
EspressoTrip-v2 Jan 28, 2026
c750a23
add existing socket to mongo proxy
EspressoTrip-v2 Jan 28, 2026
312a9dc
fix workflow
EspressoTrip-v2 Jan 28, 2026
0050a5d
version bump
EspressoTrip-v2 Jan 28, 2026
a3b453b
merge master
EspressoTrip-v2 Jan 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/quiet-melons-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@journeyapps/https-proxy-socket': patch
---

Fixed socket timeout and use mongo driver existing socket
5 changes: 5 additions & 0 deletions .changeset/vast-memes-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@journeyapps/https-proxy-socket': patch
---

Mongo hack fix, multi socket closure
18 changes: 9 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ jobs:
- name: Build
run: pnpm build

# - name: Create Release Pull Request or Publish to npm
# id: changesets
# uses: changesets/action@v1
# if: ${{ github.event_name == 'push' }}
# with:
# version: pnpm ci:version
# publish: pnpm ci:publish
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
if: ${{ github.event_name == 'push' }}
with:
version: pnpm ci:version
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Dev publish
if: ${{ github.event_name == 'workflow_dispatch' }}
Expand Down
2 changes: 1 addition & 1 deletion src/HttpsProxySocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class HttpsProxySocket {
let buffersLength = 0;

function read() {
var b = socket.read();
const b = socket.read();
if (b) {
ondata(b);
} else {
Expand Down
35 changes: 27 additions & 8 deletions src/mongoPatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,41 @@ interface Config {
/** The journey apps cc egress proxy domain */
proxy: string;
}

/**
* The patch should be called before instantiating the MongoClient
* @param config - The configuration for the proxy
*/
export function useProxyForMongo(config: Config) {
let socket: tls.TLSSocket;
let sockets: tls.TLSSocket[] = [];
socks.SocksClient.createConnection = async (options, callback) => {
const proxy = new HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
return new Promise(async (resolve, reject) => {
socket = await proxy.connect({ host: options.destination.host, port: options.destination.port });
resolve({
socket,
});
const socket = await new HttpsProxySocket({ socket: options.existing_socket }, { auth: config.auth }).connect({
host: options.destination.host,
port: options.destination.port,
});

socket.on('timeout', () => {
console.error('Socket timeout');
});
sockets.push(socket);
return {
socket,
};
};
return {
close: () => socket?.end(),
close: async () => {
await Promise.all(
sockets.map(
(socket) =>
new Promise<void>((resolve) => {
socket.once('close', () => {
resolve();
});
socket.destroySoon();
}),
),
);
sockets = [];
},
};
}
Loading