From 01ef415ddf127908e6c3d799ef6aaab291d4f2f9 Mon Sep 17 00:00:00 2001 From: meisZWFLZ Date: Mon, 1 Jan 2024 18:43:06 -0700 Subject: [PATCH] fix: :bug: prevent simultaneous refreshes --- src/VexDevice.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/VexDevice.ts b/src/VexDevice.ts index dd94cd7..534bd32 100644 --- a/src/VexDevice.ts +++ b/src/VexDevice.ts @@ -839,8 +839,9 @@ export class V5SerialDevice extends VexSerialDevice { constructor(defaultSerial: Serial) { super(defaultSerial); + let isLastRefreshComplete: boolean = true; setInterval(() => { - if (this.autoRefresh) { + if (this.autoRefresh && isLastRefreshComplete) { if (!this.isConnected) { this.state.brain.isAvailable = false; return; @@ -850,7 +851,8 @@ export class V5SerialDevice extends VexSerialDevice { this.pauseRefreshOnFileTransfer && !this.state._isFileTransferring ) { - void this.refresh(); + isLastRefreshComplete = false; + void this.refresh().finally(() => (isLastRefreshComplete = true)); } } }, 200);