Skip to content

Fix: Android crash (NPE) on any BLE error — all onError callbacks pass null as the promise rejection code#1335

Open
nas887 wants to merge 1 commit intodotintent:masterfrom
nas887:bugfix/android-crash-on-any-ble-error
Open

Fix: Android crash (NPE) on any BLE error — all onError callbacks pass null as the promise rejection code#1335
nas887 wants to merge 1 commit intodotintent:masterfrom
nas887:bugfix/android-crash-on-any-ble-error

Conversation

@nas887
Copy link
Copy Markdown

@nas887 nas887 commented Apr 2, 2026

Every onError callback in BlePlxModule.java calls: safePromise.reject(null, errorConverter.toJs(error));

The code parameter of PromiseImpl.reject is annotated @nonnull in the React Native bridge. Passing null bypasses the JS
error handler entirely and crashes the Android process with:

  java.lang.NullPointerException: Parameter specified as non-null is null:
    method com.facebook.react.bridge.PromiseImpl.reject, parameter code
    at com.bleplx.utils.SafePromise.reject(SafePromise.java:25)

This means any BLE error on Android is a fatal crash, not a catchable JS exception.

Fix: pass String.valueOf(error.errorCode.code) so the BleErrorCode integer (e.g. 401 for CharacteristicWriteFailed) is used as the rejection code, matching what the JS layer expects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant