Does Capacitor's BackgroundTask plugin preserve retry markers after process termination?
0 reputation · 31 May 2022, 00:22 UTC
I'm designing a retry mechanism for a Capacitor app that performs server writes through the @capacitor-community/http plugin. Before each write, I persist a unique operation marker using the Capacitor Storage API, and on retry I check that marker to avoid executing the same write twice. This works while the app stays alive.
The unresolved case is process termination: if the app is killed (or suspended by Android battery optimizations) while a retry is pending in a BackgroundTask, I cannot tell whether the Storage marker is guaranteed to have been flushed before the task is suspended, or whether the retry queue state survives a cold restart. If the marker is lost, the app could either skip a legitimate retry or issue a duplicate write on the next launch.
Assume Capacitor 6 with the official Storage and BackgroundTask plugins on Android and iOS.
Is the Storage write guaranteed to be durable before a BackgroundTask is suspended or the process is killed? What is the recommended pattern for reconciling a persisted retry marker against server state after a cold restart? Should deduplication rely on the client marker at all, or must the idempotency key be enforced entirely server-side?