Skip to content

Commit

Permalink
revert fancy es6 catch attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbendell committed Feb 20, 2021
1 parent 26d382a commit 06cd012
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ class Http2TLSTunnel {
tlsSocket.end();
});
tlsSocket.on('close', hadError => {
tcpSocket.end();
try {
tcpSocket.end();
}
catch (e) {
console.error(e);
}
});
this.tlsSocket = tlsSocket;
};
Expand All @@ -139,9 +144,30 @@ class Http2TLSTunnel {
}

async stop() {
if (this.tcpSocket) (await this.tcpSocket.end()).catch(e => console.log(e));
if (this.tlsSocket) (await this.tlsSocket.end()).catch(e => console.log(e));
if (this._server && this._server.listening) (await this._server.close()).catch(e => console.log(e));
if (this.tcpSocket) {
try {
await this.tcpSocket.end();
}
catch (e) {
console.error(e);
}
}
if (this.tlsSocket) {
try {
await this.tlsSocket.end()
}
catch (e) {
console.error(e);
}
}
if (this._server && this._server.listening) {
try {
await this._server.close();
}
catch (e) {
console.error(e);
}
}
}
}

Expand Down

0 comments on commit 06cd012

Please sign in to comment.