From 601da3726bb17d5f26f3f2e382f983fae89fd31d Mon Sep 17 00:00:00 2001 From: Thomas Weber Date: Fri, 31 Dec 2021 14:47:28 -0600 Subject: [PATCH] Update cloud socket close handling - Code 4004 (project blocked) is handled now - Updated some log messages --- src/scaffolding/cloud.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/scaffolding/cloud.js b/src/scaffolding/cloud.js index 77ccc7c..9e70d29 100644 --- a/src/scaffolding/cloud.js +++ b/src/scaffolding/cloud.js @@ -133,13 +133,17 @@ class WebSocketProvider { } onclose (e) { - console.log('WebSocket closed'); + // https://github.com/TurboWarp/cloud-server/blob/master/doc/protocol.md#status-codes if (e && e.code === 4002) { - console.log('WebSocket username is invalid, not reconnecting.'); + console.log('Username is invalid; not reconnecting.'); + return; + } + if (e && e.code === 4004) { + console.log('Project is blocked; not reconnecting.'); return; } const timeout = Math.random() * (Math.pow(2, Math.min(this.attemptedConnections + 1, 5)) - 1) * 1000; - console.log(`Reconnecting in ${Math.round(timeout)}ms`); + console.log(`Connection lost; reconnecting in ${Math.round(timeout)}ms`); setTimeout(this.openConnection, timeout); }