From ed358cd9d9785dd45beef05c4dd4ae42e267eedd Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Fri, 27 Nov 2026 00:56:07 -0500 Subject: [PATCH] fix(#1223): number DM attempts from 1, and stop claiming a retry that is not coming Ben read "Retry 4/5" on a failed DM and concluded the fifth attempt never ran. The log from OB-3UJZR proves it did: at 17:38:38 the client sent CMD_RESET_PATH and then attempt 4, so the flood fallback fired exactly as ruled. The label was wrong, not the loop. `retryCount` is a zero-based attempt index and `maxMessageRetries` is a count of attempts, so the chat label printed one against the other. The fifth and final attempt of five read as "4/5", which reads as a sixth attempt still to come. The AckHash log line had the same fault twice over: it printed the raw index, and it said "retrying" on the final timeout, when the message is in fact being marked failed. Both now read from 1 and say which it is. No l10n change: `chat_retryCount` keeps its "Retry {current}/{max}" form in all 18 locales and only the number passed in changes. --- lib/screens/chat_screen.dart | 8 +++++++- lib/services/message_retry_service.dart | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index a2d76ac3..49da8532 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -1949,8 +1949,14 @@ class _MessageBubble extends StatelessWidget { ? const EdgeInsets.symmetric(horizontal: 8) : EdgeInsets.zero, child: Text( + // `retryCount` is a zero-based attempt index + // and `maxMessageRetries` is a count, so + // printing them together showed the fifth and + // final attempt of five as "4/5", which reads + // as a sixth attempt still to come. The flood + // fallback had already fired by then. (#1223) context.l10n.chat_retryCount( - message.retryCount, + message.retryCount + 1, context .read() .settings diff --git a/lib/services/message_retry_service.dart b/lib/services/message_retry_service.dart index d061409f..e91fe901 100644 --- a/lib/services/message_retry_service.dart +++ b/lib/services/message_retry_service.dart @@ -678,12 +678,19 @@ class MessageRetryService extends ChangeNotifier { final shortText = message.text.length > 20 ? '${message.text.substring(0, 20)}...' : message.text; + // Attempts are numbered from 1 in anything a human reads. `retryCount` is a + // zero-based index, and printing it raw made the last attempt of five read + // as "attempt 4", which reads as a sixth attempt that never came. It also + // said "retrying" on the final timeout, when the message is being failed. + final bool willRetry = message.retryCount < maxRetries - 1; config?.debugLogService?.warn( - 'Timeout: No ACK received for "$shortText" to ${contact.name} (attempt ${message.retryCount}) → retrying', + 'Timeout: No ACK received for "$shortText" to ${contact.name} ' + '(attempt ${message.retryCount + 1} of $maxRetries)' + '${willRetry ? ' → retrying' : ' → giving up, marking failed'}', tag: 'AckHash', ); - if (message.retryCount < maxRetries - 1) { + if (willRetry) { final backoffMs = 1000 * (1 << message.retryCount); if (selection != null) {