[web-bluetooth] getPrimaryService() not resolving appropriately

NAllred91 has just created a new issue for https://github.com/WebBluetoothCG/web-bluetooth:

== getPrimaryService() not resolving appropriately ==
I'm experiencing issues with the getPrimaryService promise not resolving appropriately when refreshing the page and immediately trying to reconnect.

My user experience is the following:

- Make the initial connection to the device.
- Once the connection is completely finished, refresh the page.
- Immediately try to connect to the device again.
- May need to repeat this a few times, but eventually the connection process hangs.

In the code I'm observing that it is the `getPrimaryService` promise that simply never resolves.  I've even checked to make sure `device.gatt.connected` is true before making the call.

Once I get into this state the promise hangs indefinitely.  If I power off and power on my device and start the connection process in my browser again, without refreshing, the following happens:

- I make the call to `device.gatt.connect`
- Then, the initial call to `getPrimaryService` resolves with the error  "NetworkError: GATT Server is disconnected. Cannot retrieve services. (Re)connect first with `device.gatt.connect`."
- Then, the promise from `device.gatt.connect` resolves with the error "GATT Server disconnected while retrieving characteristics."
- At this point, I can attempt the connection again and it appears to always be successful.

I've tried to write some code to work around this edge case, (setting a timeout, telling the user to restart their device, etc...) but it seems like their might be some deeper issue here?

Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/issues/367 using your GitHub account

Received on Sunday, 7 May 2017 16:19:49 UTC