diff --git a/arduino-ide-extension/src/browser/monitor/monitor-connection.ts b/arduino-ide-extension/src/browser/monitor/monitor-connection.ts index 13031f26..8d81c08b 100644 --- a/arduino-ide-extension/src/browser/monitor/monitor-connection.ts +++ b/arduino-ide-extension/src/browser/monitor/monitor-connection.ts @@ -200,8 +200,10 @@ export class MonitorConnection { protected async handleBoardConfigChange(boardsConfig: BoardsConfig.Config): Promise { if (this.autoConnect) { if (this.boardsServiceClient.canUploadTo(boardsConfig, { silent: false })) { - this.boardsService.getAttachedBoards().then(({ boards }) => { - if (boards.filter(AttachedSerialBoard.is).some(board => BoardsConfig.Config.sameAs(boardsConfig, board))) { + // Instead of calling `getAttachedBoards` and filtering for `AttachedSerialBoard` we have to check the available ports. + // The connected board might be unknown. See: https://github.com/arduino/arduino-pro-ide/issues/127#issuecomment-563251881 + this.boardsService.getAvailablePorts().then(({ ports }) => { + if (ports.some(port => Port.equals(port, boardsConfig.selectedPort))) { new Promise(resolve => { // First, disconnect if connected. if (this.connected) {