Skip to content

Retry setMyCommands on timeout during startup - #170

Merged
Nachtalb merged 1 commit into
masterfrom
fix/setmycommands-timeout-retry
Aug 18, 2026
Merged

Retry setMyCommands on timeout during startup#170
Nachtalb merged 1 commit into
masterfrom
fix/setmycommands-timeout-retry

Conversation

@Nachtalb

Copy link
Copy Markdown
Owner

Problem

Startup log from the live pod:

22:00:36,054  setMyCommands  200 OK   ← 10th call
22:00:41,085  WARNING - Failed to set ja commands
22:00:41,162  setMyCommands  200 OK   ← next language, fine

A 5s gap, one warning, then everything after it succeeds. Not a 400 and not a
content rejection β€” the ja catalog is valid and getMyCommands?language_code=ja
returns the full Japanese menu. It's a transient httpx read timeout on one
request out of 17 back-to-back setMyCommands calls fired at startup.

Two issues that made it worse than it looks:

  1. No retry β€” a single transient timeout permanently drops that language's
    command menu for the pod's entire lifetime (commands are only set in
    post_init).
  2. logger.warning("Failed to set %s commands", lang_code) had no exc_info,
    so the warning gave no cause at all.

Change

One _set_commands_retrying helper that retries once after a 2s sleep on
TimedOut. Both the localised loop and the admin loop route through it, and
both warnings now carry exc_info=True.

Test

Added test_timeout_is_retried β€” first localised call raises TimedOut, asserts
the retry brings the total call count to 2 + n_localised. 9 tests pass, ruff
clean.

A transient httpx read timeout on one of the 17 back-to-back setMyCommands
calls at startup permanently dropped that language's command menu for the
pod's lifetime ("Failed to set ja commands"). The bare warning also logged
no cause, since exc_info was omitted.

Retry once after a short sleep on TimedOut, and log the exception for both
the localised and admin branches.
@Nachtalb
Nachtalb merged commit 7a36f11 into master Aug 18, 2026
7 checks passed
@Nachtalb
Nachtalb deleted the fix/setmycommands-timeout-retry branch August 18, 2026 19:23
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.

1 participant