fix: comprehensive React Native 0.80.0+ compatibility fix#1312
fix: comprehensive React Native 0.80.0+ compatibility fix#1312sweetbot wants to merge 1 commit intodotintent:masterfrom
Conversation
- Fix all 35 instances of null error codes in promise.reject calls - Include both safePromise.reject and promise.reject fixes - Handle both error and bleError parameter naming consistently - Address React Native 0.80.0+ null-safety requirements - Resolves crashes in BLE operations with RN 0.81.4+ Resolves: dotintent#1310
3a4dcb7 to
235d9fa
Compare
|
Hopefully this gets pulled in soon, I used patch-package to fix the current version. Thanks for making the pull request :) |
|
After upgrading our app to Expo 54 we ran into this issue; and I can confirm the suggested patch resolved it for us. |
|
This patch fixed the issue for us also. Would be great if this could be merged to the official library. |
|
Any updates? We really stuck on our update to react native 0.80.0 / expo54 |
|
I hate to say it but I did a fork of this library because I had to fix the same problem... I just reviewed your PR and it's identical to one of the problem I fixed @ArtemFokin @b1naryth1ef @alariois If you guys want to collaborate. |
|
@sfourdrinier I tried your fork and cant find the types (like BleManager) in code, import doesnt work, you should give a check. |
|
Any updates on ETA for when this PR will be merged, and the new version release? |
Problem
React Native 0.80.0 was the first release to include the PromiseImpl null-safety changes.
The React Native Commit in April 2025
"fix nullsafe FIXMEs for PromiseImpl.java and mark nullsafe"
by Gijs Weterings
4c8ea858a53 - fix nullsafe FIXMEs for PromiseImpl.java and mark nullsafe
What This Means:
React Native 0.80.0+ enforces non-null error codes in PromiseImpl.reject()
React Native 0.79.x and earlier allowed null as the error code
The change added @nullsafe(Nullsafe.Mode.LOCAL) annotation to PromiseImpl class
This triggers NullPointerException when null is passed as the error code
Root Cause
React Native 0.80.0+ added
@Nullsafe(Nullsafe.Mode.LOCAL)annotation toPromiseImplclass, which enforces non-null error codes at runtime.This bluetooth library was calling in a lot of places:
But React Native 0.80.0+ now requires:
React Native 0.80.0 was the first release to include this change that broke some features of this library
Impact
It fixes an urgent compatibility issue impacting a wide range of users forced to move to React Native 0.81.4+ (especially Expo SDK 54+ projects). Updating to Expo 54 makes it impossible to use this library without crash, since Expo 54 is only compatible with React Native 0.81.4+.
This will fix issues for Ledger reactive native Device Management SDK and other reactive native SDKs which use this library as the transport layer.
Related Issue that I reported 2 days ago: #1310 - Android crash in BLETransport APIs when React Native version is 0.81.4
Solution
Replace all
nullerror codes with properBleErrorCodeenum values usingerror.errorCode.name().Java code changes in this PR
In android/src/main/java/com/bleplx/BlePlxModule.java
safePromise.reject(null, ...)withsafePromise.reject(error.errorCode.name(), ...)promise.reject(null, ...)withpromise.reject(error.errorCode.name(), ...)promise.reject(null, ...)withpromise.reject(bleError.errorCode.name(), ...)Testing results
Error Log
Some more details of Native Android logs here: