mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 00:23:12 +09:00
Fix error during slave authentication failure
Treat sending messages over a link that is not connected as a SessionLost error and handle AuthenticationFailed error in the startup logic of slave.
This commit is contained in:
1 parent
3dfed4d2ad
commit
07cff0ab9a
3 files changed
+13
-6
No files matched your search
@@ -97,7 +97,9 @@ class WebSocketBaseConnector extends events.EventEmitter {
|
|||||||
* @returns the sequence number of the message sent
|
* @returns the sequence number of the message sent
|
||||||
*/
|
*/
|
||||||
send(type, data) {
|
send(type, data) {
|
||||||
this._check(["handshake", "connected", "closing"]);
|
if (!["handshake", "connected", "closing"].includes(this._state)) {
|
||||||
|
throw new errors.SessionLost("No session");
|
||||||
|
}
|
||||||
let message = { seq: this._seq, type, data };
|
let message = { seq: this._seq, type, data };
|
||||||
this._sendBuffer.push(message);
|
this._sendBuffer.push(message);
|
||||||
if (["connected", "closing"].includes(this._state)) {
|
if (["connected", "closing"].includes(this._state)) {
|
||||||
@@ -271,7 +273,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
|
|||||||
console.log(`SOCKET | Close (code: ${code}, reason: ${reason})`);
|
console.log(`SOCKET | Close (code: ${code}, reason: ${reason})`);
|
||||||
// Authentication failed
|
// Authentication failed
|
||||||
if (code === 4003) {
|
if (code === 4003) {
|
||||||
this.emit("error", new errors.AuthenticationFailed("Authentication failed"));
|
this.emit("error", new errors.AuthenticationFailed(reason));
|
||||||
this._state = "closing";
|
this._state = "closing";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1275,14 +1275,19 @@ I version of clusterio. Expect things to break. I
|
|||||||
`
|
`
|
||||||
);
|
);
|
||||||
startSlave().catch(err => {
|
startSlave().catch(err => {
|
||||||
console.error(`
|
if (err instanceof errors.AuthenticationFailed) {
|
||||||
|
console.error(err.message);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.error(`
|
||||||
+--------------------------------------------------------------+
|
+--------------------------------------------------------------+
|
||||||
| Unexpected error occured while starting slave, please report |
|
| Unexpected error occured while starting slave, please report |
|
||||||
| it to https://github.com/clusterio/factorioClusterio/issues |
|
| it to https://github.com/clusterio/factorioClusterio/issues |
|
||||||
+--------------------------------------------------------------+`
|
+--------------------------------------------------------------+`
|
||||||
);
|
);
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
console.error(err);
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ describe("Integration of lib/link", function() {
|
|||||||
control = new TestControl(controlConnector);
|
control = new TestControl(controlConnector);
|
||||||
await assert.rejects(
|
await assert.rejects(
|
||||||
controlConnector.connect(),
|
controlConnector.connect(),
|
||||||
new Error("Authentication failed")
|
new Error("Authentication failed: jwt malformed")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user