Skip to content

Commit

Permalink
don't retry on EINTR, fix peer url format
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Nov 28, 2024
1 parent 66cb16e commit 6efb688
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function build (color) {
} else {
peers = Object.entries(peerMap).map(([port, peer])=>{
peer = new URL(peer)
return `tcp://${peer.username}:${color}-sync-proxy:${port}`
return `tcp://${peer.username}@${color}-sync-proxy:${port}`
}).join(',')
}
console.log(peers)
Expand Down
19 changes: 5 additions & 14 deletions sync_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,11 @@ async function run (localHost, controlPort, proxyConfig) {
console.log(`🟢 ${localPort}->${remoteHost}:${remotePort}: connected`)
// Collect connection to close it on pause
connections.add(connection)
// Proxy client to server and back, retrying on EINTR
while (true) {
try {
await Promise.all([
connection.readable.pipeTo(remote.writable),
remote.readable.pipeTo(connection.writable),
])
break
} catch (e) {
if (e.code !== 'EINTR') {
throw e
}
}
}
// Proxy client to server and back
await Promise.all([
connection.readable.pipeTo(remote.writable),
remote.readable.pipeTo(connection.writable),
])
} catch (e) {
if (e.code) {
console.error(`🔴 ${localPort}->${remoteHost}:${remotePort}: ${e.code}`)
Expand Down

0 comments on commit 6efb688

Please sign in to comment.