attempt to insert nil object from objects[2]' was thrown while invoking getConnectedPeripherals on target BleManager with params
See original GitHub issueI found existing closed issue 134 that says this has been fixed since 3.2.1…
Version
- “react-native-ble-manager”: “^6.2.9”,
- “react-native”: “0.52.1”,
- iOS/Android I’m testing on both but only seen this error on iOS iPhone6
Expected behaviour
promise to be resolved or rejected without exception
Actual behaviour
This doesn’t always happen. I’ve only seen it after a crash and when I’ve restarted the app.
Steps to reproduce
my code:
connect(peripheral) {
this.log.info('BLE Connect requested', peripheral.id);
return BleManager.getConnectedPeripherals([])
.then((peripheralsArray) => {
// Success code
let idx = _.findIndex(peripheralsArray,{id:peripheral.id});
this.log.info('BLE Connected peripherals: ',peripheralsArray,idx);
if (idx >= 0){
this.log.info('BLE WE ARE CONNECTED TO DEVICE ALREADY; DISCONNECTING', peripheral.id);
return BleManager.disconnect(peripheral.id);
}
})
.then(() => BleManager.connect(peripheral.id))
.then(()=> BleManager.getConnectedPeripherals([]))
.then((devices) => {
this.log.info('BLE Connected to', devices);
})
.then(() => BleManager.retrieveServices(peripheral.id))
.then((peripheralInfo) => {
this.log.info('BLE Service info:' ,peripheralInfo);
return Promise.resolve(peripheralInfo);
});
}
As you can see in the stack trace I get the first log message but not the second found in the first .then(). I tested the _.findIndex() with possible values and it does not seem to be a problem.
Stack trace and console log
09:11:27.616 debug-service.js:320 BLE Connect requested 90B8E3E4-6917-79AD-390E-A6D99EFFF75B
ExceptionsManager.js:71 Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]' was thrown while invoking getConnectedPeripherals on target BleManager with params (
(
),
5143
)
callstack: (
0 CoreFoundation 0x00000001826e6da4 <redacted> + 252
1 libobjc.A.dylib 0x00000001818a05ec objc_exception_throw + 56
2 CoreFoundation 0x000000018267f750 _CFArgv + 0
3 CoreFoundation 0x00000001825b80cc <redacted> + 352
4 CoreFoundation 0x00000001825b7f48 <redacted> + 64
5 aura-test 0x0000000100538f58 dataToArrayBuffer + 268
6 aura-test 0x0000000100539464 -[CBPeripheral(com_megster_ble_extension) serviceAndCharacteristicInfo:] + 1180
7 aura-test 0x0000000100538394 -[CBPeripheral(com_megster_ble_extension) asDictionary] + 936
8 aura-test 0x000000010053c590 -[BleManager getConnectedPeripherals:callback:] + 908
9 CoreFoundation 0x00000001826ee580 <redacted> + 144
10 CoreFoundation 0x00000001825cd748 <redacted> + 284
11 CoreFoundation 0x00000001825d256c <redacted> + 60
12 aura-test 0x00000001003427f4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2064
13 aura-test 0x00000001003ed1ec _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 664
14 aura-test 0x00000001003ecd70 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 132
15 aura-test 0x00000001003ecce0 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
16 libdispatch.dylib 0x0000000100e451dc _dispatch_call_block_and_release + 24
17 libdispatch.dylib 0x0000000100e4519c _dispatch_client_callout + 16
18 libdispatch.dylib 0x0000000100e53dfc _dispatch_queue_serial_drain + 768
19 libdispatch.dylib 0x0000000100e486ac _dispatch_queue_invoke + 328
20 libdispatch.dylib 0x0000000100e54d54 _dispatch_root_queue_drain_deferred_wlh + 352
21 libdispatch.dylib 0x0000000100e5be38 _dispatch_workloop_worker_thread + 676
22 libsystem_pthread.dylib 0x000000018230be70 _pthread_wqthread + 860
23 libsystem_pthread.dylib 0x000000018230bb08 start_wqthread + 4
)
reactConsoleErrorHandler @ ExceptionsManager.js:73
console.error @ YellowBox.js:71
logToConsole @ RCTLog.js:48
logIfNoNativeHook @ RCTLog.js:31
__callFunction @ MessageQueue.js:353
(anonymous) @ MessageQueue.js:118
__guardSafe @ MessageQueue.js:316
callFunctionReturnFlushedQueue @ MessageQueue.js:117
t @ RNDebuggerWorker.js:1
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
attempt to insert nil object from objects[2]' was thrown while ...
attempt to insert nil object from objects[2]' was thrown while invoking getConnectedPeripherals on target BleManager with params.
Read more >attempt to insert nil object from objects[0] - Stack Overflow
We were trying to run this on an iPhone 11 Simulator. As of now, we have been getting this error attempt to insert...
Read more >@pija-ab/react-native-ble-manager - npm
Start the notification on the specified characteristic, you need to call retrieveServices method before. Returns a Promise object. Arguments.
Read more >iOS Question Attempt to insert nil object from objects[2] error
As I said in some cases Finish has a value NULL in the database and when I read it string Finish gets value...
Read more >react-native-ble-plx 2.0.2 | Documentation
Only one instance of BleManager is allowed. When you don't need any BLE functionality you can destroy created instance by calling this.manager.destroy() ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had almost the same problem, but it seems to be because of BleManager.retrieveServices, when I loged the recieved value from
[charachteristic value]
I got an empty NSData, sodataToArrayBuffer
crashed and created the problem I had. I managed to fix it by adding this to line 198 in CBPeripheral+Extensions.mMaybe you have a similar problem and this can help you out.
I’ve not seen this since adding @folofse solution above. I think it is even in the codebase now.