From 6c306ec0657034afb73c9030dd82aae85b69785c Mon Sep 17 00:00:00 2001 From: Kouji Takao Date: Sun, 25 Jan 2026 20:39:09 +0900 Subject: [PATCH] fix: catch GATT server disconnected error in MicrobitMore - Added .catch() to BLE read operations in updateState and updateMotion - Ensures bleBusy flag is cleared and error is logged - Prevents unhandled promise rejections when BLE connection is lost Co-Authored-By: Gemini --- src/extensions/microbitMore/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/extensions/microbitMore/index.js b/src/extensions/microbitMore/index.js index 6f1871f3d0..3719bef202 100644 --- a/src/extensions/microbitMore/index.js +++ b/src/extensions/microbitMore/index.js @@ -858,6 +858,12 @@ class MbitMore { this.soundLevel = dataView.getUint8(6); this.resetConnectionTimeout(); resolve(this); + }) + .catch(err => { + window.clearTimeout(this.bleBusyTimeoutID); + this.bleBusy = false; + log.error(err); + resolve(this); }); }); } @@ -999,6 +1005,12 @@ class MbitMore { this.magneticForce.z = dataView.getInt16(16, true); this.resetConnectionTimeout(); resolve(this); + }) + .catch(err => { + window.clearTimeout(this.bleBusyTimeoutID); + this.bleBusy = false; + log.error(err); + resolve(this); }); }); }