-
-
Notifications
You must be signed in to change notification settings - Fork 8
Description
stoprocent/node-bluetooth-hci-socket@59744ec refactored a great deal of the hci-socket binding. It replaced Node's ErrnoException with a custom error construction: https://github.com/stoprocent/node-bluetooth-hci-socket/blob/2dca8d87438fb1feb37db4e6bc75b568eddda0ff/src/BluetoothHciSocket.cpp#L80-L82
However, the onSocketError parser was never updated to deal with EPERM, which is now encoded as an integer in errno, rather than as a string in code:
Line 937 in e2f1db9
| else if (error.code === 'EPERM') { |
The result is that initialization can "hang" if permissions are wrong. It also causes stop() to hang forever:
$ DEBUG=\* node advertisement-discovery.js
Waiting for Bluetooth adapter...
hci reset - writing: 01030c00 +0ms
hci onSocketError: Operation not permitted +0ms
hci setting filter to: 1600000020c10800000000400000 +0ms
hci le read supported feature - writing: 01032000 +0ms
hci onSocketError: Operation not permitted +0ms
^C
Cleaning up...
noble stopping
hci set scan enabled - writing: 010c20020001 +6s
hci onSocketError: Operation not permitted +1ms
noble scanStop +0ms(In matter.js, discovery just sits there silently doing nothing.)
The old ErrnoException actually contains both: https://github.com/nodejs/node/blob/3810024f003f3a3756cbf82393f24f54f447be59/src/api/exceptions.cc#L57-L60
I'm not sure what the best course of action is here. EPERM=1 on my Ubuntu machine, but I guess it would be nice to use a string for compatibility.