Skip to content

feat: configurable timeout + auto-retry for headless login#10

Open
okuegow wants to merge 1 commit into
RustyDust:mainfrom
okuegow:feat/timeout-retry
Open

feat: configurable timeout + auto-retry for headless login#10
okuegow wants to merge 1 commit into
RustyDust:mainfrom
okuegow:feat/timeout-retry

Conversation

@okuegow
Copy link
Copy Markdown

@okuegow okuegow commented Jun 2, 2026

The Bluelink backend often needs a warm-up on the first call after a quiet period (cold session); curl_cffi's default ~10s timeout then surfaces as a hard failure. Reported by Genesis users in evcc-io/evcc#30223 but applies to all brands — Kia/Hyundai owners with a car that sleeps will hit the same cold-call symptom.

What changes

  • headless_login() gains a timeout=30 keyword argument and passes it to all four HTTP calls (authorize / certs / signin / token-exchange). Previous behaviour relied on curl_cffi's ~10s default.
  • main() exposes two new CLI flags:
    • --timeout <seconds> — default 30, bump to 60+ on slow networks.
    • --retries <n> — default 1 (= one retry after a failure, two attempts total). Use 0 to disable retries.
  • main() wraps headless_login() in a retry loop that only catches transport errors (curl_cffi.requests.exceptions.RequestException / OSError). Auth failures, missing code in redirect, HTTP-status problems etc. still sys.exit from inside headless_login(), so retries do not paper over real errors.

Why these defaults

  • Default timeout 30s balances cold-backend coverage against not making auth failures hang too long. Users with reliable networks can lower it; users on slow setups can raise it.
  • One automatic retry is enough to handle the common cold-call pattern (second call is fast because the backend session is warm). More retries are user-configurable.

Compatibility

  • Browser flow unchanged.
  • All new params have defaults; existing callers / pipelines see no API break.
  • Tested locally on a Genesis EU account (1 attempt, 1 retry, default timeout); auth succeeded on first attempt under normal conditions.

Independent of #9 (Genesis brand) — they don't touch the same lines.

The Bluelink backend often needs a warm-up on the first call after a
quiet period (cold session). Reported by Genesis users in
evcc-io/evcc#30223 but applies to all brands.

Changes:
- headless_login() now accepts a timeout= keyword (default 30s) and
  passes it to all four HTTP calls. Previous behaviour relied on
  curl_cffi's ~10s default.
- main() exposes --timeout <s> and --retries <n> (default 1, i.e. one
  retry after a failure = two attempts total).
- main() wraps headless_login() in a retry loop that only catches
  transport errors (curl_cffi RequestException / OSError). Auth
  failures and HTTP-status problems still sys.exit immediately, so
  retries do not paper over real errors.

No change to the browser flow.
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