recordSyncFailure method

  1. @override
Future<void> recordSyncFailure(
  1. String queueEntryId,
  2. String error, {
  3. DateTime? nextRetryAt,
  4. bool incrementRetryCount = true,
})
override

Records a failed push attempt for queueEntryId.

0.2.0 semantics:

  • Stores error in last_error.
  • If incrementRetryCount (default true), increments retry_count.
  • Writes nextRetryAt to the entry's next_retry_at column. Pass null to clear (rare; engine always passes a value when called for a real failure).

Pass incrementRetryCount: false and omit nextRetryAt to retain 0.1.0 "just record the error" behaviour. Atomic with transaction.

Implementation

@override
Future<void> recordSyncFailure(
  String queueEntryId,
  String error, {
  DateTime? nextRetryAt,
  bool incrementRetryCount = true,
}) async {
  final i = _queue.indexWhere((e) => e.id == queueEntryId);
  if (i < 0) throw StateError('Queue entry $queueEntryId not found');
  final cur = _queue[i];
  _queue[i] = cur.copyWith(
    lastError: error,
    retryCount: incrementRetryCount ? cur.retryCount + 1 : cur.retryCount,
    nextRetryAt: nextRetryAt,
  );
}