Skip to content

fix(ble): prevent app crash on sendResponse to disconnected central (COLUMBA-6Q) - #1088

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/ble-sendresponse-crash
Open

fix(ble): prevent app crash on sendResponse to disconnected central (COLUMBA-6Q)#1088
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/ble-sendresponse-crash

Conversation

@sentry

@sentry sentry Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a NullPointerException that occurs when the BleGattServer attempts to send a GATT response (gattServer?.sendResponse(...)) to a BLE central device that has disconnected during the asynchronous processing of a GATT request (e.g., read/write/descriptor request).

The root cause is an internal RuntimeException thrown by the Android Bluetooth system service when it cannot resolve the connection ID for a disconnected device. This exception is parceled back to the app process, leading to a crash because the sendResponse calls were not wrapped in a try/catch block that handles RuntimeException.

Previous attempts to fix this issue (PR #700, PR #843) misdiagnosed the problem as a Kotlin null-unboxing issue related to the offset parameter, which did not resolve the underlying framework exception.

This fix introduces a safeSendResponse helper function that wraps the gattServer?.sendResponse(...) call in a try/catch(RuntimeException). This prevents the app from crashing by gracefully handling the exception when a central disconnects, logging a warning instead. All existing gattServer?.sendResponse(...) calls in BleGattServer have been updated to use this new safe helper.

Fixes COLUMBA-6Q

@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents a framework-originated exception from crashing the Reticulum host process when a BLE central disconnects during GATT request processing.

  • Adds a centralized safeSendResponse wrapper that catches and logs RuntimeException.
  • Routes characteristic and descriptor read/write responses through the wrapper.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issues identified.

The helper preserves every existing GATT response argument and call condition while preventing the documented disconnected-central framework exception from escaping into the host process.

Important Files Changed

Filename Overview
rns-host/src/main/kotlin/network/columba/app/rns/host/ble/server/BleGattServer.kt Centralizes GATT response exception handling and consistently applies it to all response paths without changing response payloads or request branching.

Reviews (1): Last reviewed commit: "fix(ble): prevent app crash on sendRespo..." | Re-trigger Greptile

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.

0 participants