fix(weixin): raise descriptive error when rate-limit retries exhaust
The rate-limit branch added by the original PR did sleep+continue with no attempt to record the last error, so persistent iLink -2 responses exhausted the retry loop and hit 'assert last_error is not None', raising AssertionError instead of a descriptive RuntimeError. Record last_error = RuntimeError(...) before continuing, and break out of the loop on the final attempt instead of sleeping uselessly.
This commit is contained in:
parent
d3a9c69e9b
commit
c69310c625
@ -1538,7 +1538,16 @@ class WeixinAdapter(BasePlatformAdapter):
|
||||
or errcode == RATE_LIMIT_ERRCODE
|
||||
)
|
||||
if is_rate_limited:
|
||||
wait = self._send_chunk_retry_delay_seconds * 3 # 3s backoff for rate limit
|
||||
errmsg = resp.get("errmsg") or resp.get("msg") or "rate limited"
|
||||
# Record the error so we raise a descriptive
|
||||
# RuntimeError (instead of AssertionError) if the
|
||||
# loop exhausts with the server still rate-limiting.
|
||||
last_error = RuntimeError(
|
||||
f"iLink sendmessage rate limited: ret={ret} errcode={errcode} errmsg={errmsg}"
|
||||
)
|
||||
if attempt >= self._send_chunk_retries:
|
||||
break
|
||||
wait = self._send_chunk_retry_delay_seconds * 3 # 3x backoff for rate limit
|
||||
logger.warning(
|
||||
"[%s] rate limited for %s; backing off %.1fs before retry",
|
||||
self.name, _safe_id(chat_id), wait,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user