You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[web-bluetooth] Bluetooth device connection promise not resolving if device times out #668
There seems to be a bug in the web-bluetooth/automatic-reconnect example or in the way web bluetooth is implemented in Chrome.
I have already filed a bug-report for Chrome, but since this may relate to API changes the bug may be caused by the fact that the sample code is out of date.
The problem:
Bluetooth device connection promise not resolving if device times out.
Select BTLE device
(Tested with Wahoo Cadence Sensor and Wahoo Heart Rate Sensor)
Wait for the device to connect
Let the sensor rest until it disconnects
Wait for the 'gattserverdisconnected' event to be triggered and the first reconnect cycle to start
The program will stall and the requestDevice() chooser will stop responding
What is the expected behavior?
The bluetoothDevice.gatt.connect() call should time out after some time if the client can not connect to the server. This does happen if the client disconnects but not the server (The BT device).
What went wrong?
The bluetoothDevice.gatt.connect() Promise seems to never get resolved. This does only happen if the device times out. If the device is removed via bluetoothDevice.gatt.disconnect() the API behaves as expected.
Chrome version: 79.0.3945.130 Channel: stable
OS Version: OS X 10.15.2
Sorry to bother you almost four years later, did you find a workaround for this issue? The issue does not seem to happen on my Windows machine but still seems to be a problem on Mac.
MacOS: 15.0.1 (24A348)
Chrome: Version 130.0.6723.70 (Official Build) (arm64)
Funny that you ask about this now, as I happened to revisit that part of the code yesterday and thought to myself, I wonder if this is still an issue in Chromium today! For me this issue only occurred with a specific heart-rate sensor that would sometimes disconnect after (and during) the initialization process. I ended up giving users the option to remove the sensor in the device manager of my app. But yea that is not a work-around just taking the L and moving on I guess. Could you tell me the sensor type, brand, and model you’re experiencing this issue with?
This is actually happening with a Bosh laser rangefinder, Bosch PLR 50C. The steps to reproduce and the symptoms are quite similar to yours. Just that it seems to happen when the browser tab isn't active, such as leaving the tab out of focus for a while or locking the computer. When the script tries to reconnect it wont make it past the reconnection stage. No error is thrown and the device selection dialogue won't open after that without a refresh.
One theory is that the macs bluetooth api won't answer the chrome tab if it isn't active and chrome is left hanging, but that's just a hunch at the moment. Debugging is a bit slow since I'm not on a mac myself and I have to bother someone else every time I have something to try.
Early reports appear to date back to 2015. I'm really trying to get the ball rolling on this one, it's pretty crazy that this issue is still unresolved.
Please also chime in via that Chromium link if you're still invested in getting this solved 👍
Activity
PointerEvent commentedon Oct 30, 2024
Sorry to bother you almost four years later, did you find a workaround for this issue? The issue does not seem to happen on my Windows machine but still seems to be a problem on Mac.
MacOS: 15.0.1 (24A348)
Chrome: Version 130.0.6723.70 (Official Build) (arm64)
olivierklaver commentedon Oct 30, 2024
Funny that you ask about this now, as I happened to revisit that part of the code yesterday and thought to myself, I wonder if this is still an issue in Chromium today! For me this issue only occurred with a specific heart-rate sensor that would sometimes disconnect after (and during) the initialization process. I ended up giving users the option to remove the sensor in the device manager of my app. But yea that is not a work-around just taking the L and moving on I guess. Could you tell me the sensor type, brand, and model you’re experiencing this issue with?
PointerEvent commentedon Oct 31, 2024
This is actually happening with a Bosh laser rangefinder, Bosch PLR 50C. The steps to reproduce and the symptoms are quite similar to yours. Just that it seems to happen when the browser tab isn't active, such as leaving the tab out of focus for a while or locking the computer. When the script tries to reconnect it wont make it past the reconnection stage. No error is thrown and the device selection dialogue won't open after that without a refresh.
One theory is that the macs bluetooth api won't answer the chrome tab if it isn't active and chrome is left hanging, but that's just a hunch at the moment. Debugging is a bit slow since I'm not on a mac myself and I have to bother someone else every time I have something to try.
mgibbs189 commentedon Jan 25, 2025
Same thing here. Here's the relevant Chromium issue: https://issues.chromium.org/issues/40502943
Early reports appear to date back to 2015. I'm really trying to get the ball rolling on this one, it's pretty crazy that this issue is still unresolved.
Please also chime in via that Chromium link if you're still invested in getting this solved 👍
Bound BLE gatt.connect() with a timeout to fix stuck reconnects (#15)