ERROR Invariant Violation: No callback found with version 8.4.3
See original GitHub issueDescribe the bug If the device is disconnected on write the app crashes with:
Metro logs:
Invariant Violation: No callback found with cbID 18325 and callID 9162 for BleManager.write - most likely the callback was already invoked. Args: '["Device disconnected"]', js engine: hermes
LogCat output:
FATAL EXCEPTION: main
Process: <redacted:bundleId>, PID: 16050
java.lang.RuntimeException: Illegal callback invocation from native module. This callback type only permits a single invocation from native code.
at com.facebook.react.bridge.CallbackImpl.invoke(CallbackImpl.java:26)
at it.innove.Peripheral$6.run(Peripheral.java:681)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7870)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
It looks like the issue from https://github.com/innoveit/react-native-ble-manager/issues/885 but on writing data. Or perhaps the issue is not fixed completely? So I added a try/catch block:
JS Code with try/catch:
try {
return await this.manager.write(deviceId, serviceUUID, characteristicUUID, valueByteArray, 512)
} catch (e) {
console.log('write failed', e)
}
Metro logs with try/catch:
write failed Device disconnected
Edit: sometimes I get:
write failed Error writing <redacted:deviceId> status=133
without App crash. So timing is also a thing.
But LogCat output is the same and the app is still crashing.
To Reproduce
- write data (with response)
- disconnect device (e.g. by removing battery)
Expected behavior A catchable exception without crash.
Smartphone (please complete the following information):
- Device: Pixel 3a
- OS: android 12
- react-native-ble-manager version: 8.4.3
- react-native version: 0.69.5
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Invariant Violation: no callback found with cbID for module ...
In my case this was due to a mismatch between the JS react-native version and the native version.
Read more >No callback found when upgrading to Expo 46 & 47 #19870
These errors happen right when the app starts up and doesn't allow the app to get past the loading screen. ERROR Invariant Violation:...
Read more >RFC 7530: Network File System (NFS) Version 4 Protocol
The file locking support is structured so that an RPC callback mechanism is not required. This is a departure from the previous versions...
Read more >Bash Reference Manual - GNU.org
If the failglob shell option is set, and no matches are found, an error message is printed and the command is not executed....
Read more >Master thesis Ramon Onis!
Time/space performance of invariant violation (no violations reachable)101 ... users find and correct command made modeling errors.
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
works great for me … so I pushed the PR : https://github.com/innoveit/react-native-ble-manager/pull/923
ok, i’ve think I’ve found something. the callback is not reset after sendBackrError() is called. then the callback is called an second time when the onConnectionStateChange() loop on the callback to clear all pending callbacks.