Handling SQLite error 13

Hello,

I have an issue with handling SQLite error during couchbase sync.

I’m working on react-native android app that use couchbase community edition (v3.2.2)
During the sync process, when device is running out of disk space I want to handle it by informing the user and stopping the sync process.

I have a replicator change listener that should have change.status.error but this error is not appearing there.

I also tried to handle couchbase exceptions globally in the app but also there was no success.

I can see the SQLite error in android logs:

2025-03-24 15:03:30.944 10409-10677 CouchbaseL...REPLICATOR com.app                    W  Obj=/JRepl@1106012647/C4RemoteRepl#4/Repl#5/Inserter#8/ Coll=0 Failed to insert 'b507c82e-5e0c-4578-8818-e3ddf14defce' #1-606da38124889e0597e39b5b9f56b2e3 : POSIX error 28, "No space left on device"
2025-03-24 15:03:30.945 10409-10677 CouchbaseLite/DATABASE  com.app                    E  SQLite error (code 13): statement aborts at 151: [INSERT OR IGNORE INTO "kv_default" (version, body, extra, flags, sequence, key) VALUES (?, ?, ?, ?, ?, ?)] database or disk is full
2025-03-24 15:03:30.946 10409-10677 CouchbaseLite/DATABASE  com.app                    E  database or disk is full (13/13)

Replicator change listener looks like this

this.listenerToken = this.replicator!!.addChangeListener { change: ReplicatorChange ->
                context
                    .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
                    .emit("CouchbaseSyncStatus", Gson().toJson(change.status))
            }

I searched the documentation and this forum but I coudn’t find any clear way to handle this kind of errors.

Does anyone has similar issue or might have an idea how to handle this type of errors?

Change listeners can’t trigger errors. To stop a replication you have to call its stop method.

But if the replicator is already hitting SQLite errors, it should stop by itself without you needing to do anything.