1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix crash on terminal close

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-12-03 10:00:19 -05:00
parent d73df7fe0d
commit 223149d13c
2 changed files with 11 additions and 3 deletions

View File

@ -269,6 +269,10 @@ export abstract class ShellSession {
break; break;
} }
} catch (error) { } catch (error) {
if (error?.message === "ioctl(2) failed, EBADF") {
return;
}
logger.error(`[SHELL-SESSION]: failed to handle message for ${this.terminalId}`, error); logger.error(`[SHELL-SESSION]: failed to handle message for ${this.terminalId}`, error);
} }
}) })

View File

@ -143,11 +143,14 @@ export class WebSocketApi<Events extends WebSocketEvents> extends (EventEmitter
} }
destroy() { destroy() {
if (!this.socket) return; if (!this.socket) {
return;
}
this.clearAllListeners();
this.socket.close(); this.socket.close();
this.socket = null; this.socket = null;
this.pendingCommands = []; this.pendingCommands = [];
this.clearAllListeners();
clearTimeout(this.reconnectTimer); clearTimeout(this.reconnectTimer);
clearInterval(this.pingTimer); clearInterval(this.pingTimer);
this.readyState = WebSocketApiState.PENDING; this.readyState = WebSocketApiState.PENDING;
@ -197,7 +200,8 @@ export class WebSocketApi<Events extends WebSocketEvents> extends (EventEmitter
if (error) { if (error) {
const { reconnectDelay } = this.params; 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; const url = this.socket.url;
this.writeLog("will reconnect in", `${reconnectDelay}s`); this.writeLog("will reconnect in", `${reconnectDelay}s`);