diff --git a/src/main/shell-session/shell-session.ts b/src/main/shell-session/shell-session.ts index b171986d56..d0cf7c69e3 100644 --- a/src/main/shell-session/shell-session.ts +++ b/src/main/shell-session/shell-session.ts @@ -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); } }) diff --git a/src/renderer/api/websocket-api.ts b/src/renderer/api/websocket-api.ts index 7b9144d325..d94bfb851b 100644 --- a/src/renderer/api/websocket-api.ts +++ b/src/renderer/api/websocket-api.ts @@ -143,11 +143,14 @@ export class WebSocketApi 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 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`);