Fix crash on terminal close

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2021-12-03 10:01:37 -05:00
1 parent d73df7fe0d
commit 223149d13c
2 files changed
+11 -3

No files matched your search

+4
View File
@@ -269,6 +269,10 @@ export abstract class ShellSession {
break;
}
} catch (error) {
if (error?.message === "ioctl(2) failed, EBADF") {
return;
}
logger.error(`[SHELL-SESSION]: failed to handle message for ${this.terminalId}`, error);
}
})
+7 -3
View File
@@ -143,11 +143,14 @@ export class WebSocketApi<Events extends WebSocketEvents> extends (EventEmitter
}
destroy() {
if (!this.socket) return;
if (!this.socket) {
return;
}
this.clearAllListeners();
this.socket.close();
this.socket = null;
this.pendingCommands = [];
this.clearAllListeners();
clearTimeout(this.reconnectTimer);
clearInterval(this.pingTimer);
this.readyState = WebSocketApiState.PENDING;
@@ -197,7 +200,8 @@ export class WebSocketApi<Events extends WebSocketEvents> extends (EventEmitter
if (error) {
const { reconnectDelay } = this.params;
if (reconnectDelay) {
// Only reconnect if the socket is still present (wasn't a WebSocket.destory() call)
if (reconnectDelay && this.socket) {
const url = this.socket.url;
this.writeLog("will reconnect in", `${reconnectDelay}s`);