From c4774b988a017f23ef15d3e22893943d4906e8ae Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Mar 2026 14:26:03 +0000 Subject: [PATCH] Fix null _queue race condition in uart.js write() bindUser() sets _mode on line 50 but creates _queue on line 71. If write() is called between these two points (e.g. during reconnection), the mode check passes but _queue is still null, causing a crash. Add a null guard for _queue in the write() condition. https://claude.ai/code/session_01HkebHixb3ASRumcrKYRD8p --- lib/uart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uart.js b/lib/uart.js index a142c18..0912bc1 100644 --- a/lib/uart.js +++ b/lib/uart.js @@ -235,7 +235,7 @@ class BluetoothHciSocket extends EventEmitter { write (data) { debug(`Write: ${data.toString('hex')}`); - if (this._mode === 'raw' || this._mode === 'user') { + if ((this._mode === 'raw' || this._mode === 'user') && this._queue) { this._queue.push(data); } }