From 9b58c9d0c85da5d6160c4fe934c1c43549eb23e2 Mon Sep 17 00:00:00 2001 From: Alberto Iannaccone Date: Tue, 10 May 2022 15:53:48 +0200 Subject: [PATCH] delete duplex when connection is closed --- arduino-ide-extension/src/node/monitor-service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arduino-ide-extension/src/node/monitor-service.ts b/arduino-ide-extension/src/node/monitor-service.ts index 35f77f45..eabc3915 100644 --- a/arduino-ide-extension/src/node/monitor-service.ts +++ b/arduino-ide-extension/src/node/monitor-service.ts @@ -121,11 +121,13 @@ export class MonitorService extends CoreClientAware implements Disposable { this.duplex = client.monitor(); this.duplex .on('close', () => { + this.duplex = null; this.logger.info( `monitor to ${this.port?.address} using ${this.port?.protocol} closed by client` ); }) .on('end', () => { + this.duplex = null; this.logger.info( `monitor to ${this.port?.address} using ${this.port?.protocol} closed by server` ); @@ -218,7 +220,6 @@ export class MonitorService extends CoreClientAware implements Disposable { // It's enough to close the connection with the client // to stop the monitor process this.duplex.end(); - this.duplex = null; this.logger.info( `stopped monitor to ${this.port?.address} using ${this.port?.protocol}` );