Skip to content

Fix crash on Incoming Message class - #83

Merged
AbhijeetMallick merged 2 commits into
mainfrom
task/incoming-message-persistence-crash-fix
Aug 10, 2026
Merged

AbhijeetMallick merged 2 commits into
mainfrom
task/incoming-message-persistence-crash-fix

Conversation

@AbhijeetMallick

Copy link
Copy Markdown
Collaborator

Problem:
On devices where the SQLite message store fails to initialize, the app falls back to an in-memory store. When MQTTCourierClient.destroy() attempts to delete pending messages using NSBatchDeleteRequest, it crashes with NSInternalInconsistencyException: "Unknown command type ". This is because NSBatch*Request is only supported on SQLite stores, not in-memory stores.

Solution:
Added useSafeDeleteForNonSQLiteStore flag (defaults to true) to IncomingMessagePersistence
Track which store type was actually initialized (resolvedStoreType)
Route deletion based on store type:
SQLite store → use fast NSBatchDeleteRequest (unchanged)
In-memory store → use safe fetch-and-delete loop (works on all store types)
Flag can be set to false to revert to old behavior if needed

@AbhijeetMallick
AbhijeetMallick merged commit 4ca243f into main Aug 10, 2026
1 check passed
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.

3 participants