Skip to content

Commit 5bade92

Browse files
committed
fix: retry mechanism broken
We should retry in case of Request Timeout (408) or Service Unavailable (503). The retry mechanism broke as result of commit c2fd342 (exit with an error if server unexpectedly closes the connection). This commit fixes the broken retry mechanism.
1 parent 8fa2d7b commit 5bade92

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/APIClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class APIClient {
5555
});
5656
this.socket.addEventListener("open", resolve);
5757
this.socket.on("unexpected-response", (req, res) => {
58+
this.closed = true;
5859
this.socket.close();
5960
const RequestTimeout = 408;
6061
const ServiceUnavailable = 503;
@@ -110,6 +111,7 @@ export class APIClient {
110111

111112
console.log(`Retrying connection to ${this.server}...`);
112113
this.socket = this.createSocket(this.token, this.server);
114+
this.closed = false;
113115
await this.connectSocket(this.socket);
114116
}
115117

0 commit comments

Comments
 (0)