fix(weixin): use time.monotonic() for QR-poll deadline

`_run_qr_flow` computes a QR-code login deadline from `time.time()` and
loops until wall-clock passes it. `time.time()` is not monotonic — an
NTP step, suspend/resume, or manual clock adjustment can cause the loop
to exit early (forward jump) or extend far beyond `timeout_seconds`
(backward jump).

Switch to `time.monotonic()`, which is the documented Python choice for
interval timing and is immune to wall-clock jumps. Same bug class as
#12002 and the companion feishu QR-poll fix.
This commit is contained in:
Alexazhu 2026-04-18 15:27:05 +08:00
parent 73bccc94c7
commit f884bfadcd

View file

@ -1024,11 +1024,11 @@ async def qr_login(
except Exception as _qr_exc:
print(f"(终端二维码渲染失败: {_qr_exc},请直接打开上面的二维码链接)")
deadline = time.time() + timeout_seconds
deadline = time.monotonic() + timeout_seconds
current_base_url = ILINK_BASE_URL
refresh_count = 0
while time.time() < deadline:
while time.monotonic() < deadline:
try:
status_resp = await _api_get(
session,