mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Fix sending log messages across invalid link (#639)
This commit is contained in:
1 parent
2c2521a688
commit
dbc79779ea
2 files changed
+22
-1
No files matched your search
@@ -34,6 +34,7 @@ export abstract class BaseConnector extends events.EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract send(message: libData.MessageRoutable): void;
|
protected abstract send(message: libData.MessageRoutable): void;
|
||||||
|
abstract get valid(): boolean;
|
||||||
|
|
||||||
forward(message: libData.MessageRoutable) {
|
forward(message: libData.MessageRoutable) {
|
||||||
const seq = this._seq;
|
const seq = this._seq;
|
||||||
@@ -346,6 +347,14 @@ export abstract class WebSocketBaseConnector extends BaseConnector {
|
|||||||
get hasSession() {
|
get hasSession() {
|
||||||
return ["connected", "resuming"].includes(this._state);
|
return ["connected", "resuming"].includes(this._state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the connector is valid and can accept new messages,
|
||||||
|
* only needs to be checked on fringe cases during setup and tear down.
|
||||||
|
*/
|
||||||
|
get valid() {
|
||||||
|
return this.hasSession;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -723,4 +732,14 @@ export class VirtualConnector extends BaseConnector {
|
|||||||
send(message: libData.Message) {
|
send(message: libData.Message) {
|
||||||
this.other.emit("message", message);
|
this.other.emit("message", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the connector is valid and can accept new messages,
|
||||||
|
* only needs to be checked on fringe cases during setup and tear down.
|
||||||
|
*
|
||||||
|
* For a virtual connector this is always true.
|
||||||
|
*/
|
||||||
|
get valid() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,9 @@ export class LinkTransport extends Transport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.link.send(new libData.LogMessageEvent(info));
|
if (this.link.connector.valid) {
|
||||||
|
this.link.send(new libData.LogMessageEvent(info));
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Ignore session lost errors.
|
// Ignore session lost errors.
|
||||||
if (!(err instanceof libErrors.SessionLost)) {
|
if (!(err instanceof libErrors.SessionLost)) {
|
||||||
|
|||||||
Reference in new issue
Block a user