yikart/AiToEarn · error · HttpException
系统错误
Error message
系统错误
What it means
sendRedPacket calls WeChat Pay via a third-party relay that returns SYSTEM_ERROR with status 500. The service retries with increasing backoff (1s, 2s, ...), and once retry exceeds 5 it gives up and throws HttpException('系统错误', 500). This means the WeChat red-packet endpoint kept failing server-side through all retries.
Source
Thrown at project/aitoearn-electron/server/src/lib/wx/wxPay.service.ts:154
batch_remark: '提现红包',
total_amount: transAmount * 100,
total_num: 1,
transfer_detail_list: [
{
out_detail_no: outBizNo,
transfer_amount: transAmount * 100,
transfer_remark: '提现红包',
openid: openId,
},
],
});
if (result.status === 200) {
return result;
} else if (result.error === 'SYSTEM_ERROR' && result.status === 500) {
Logger.error('系统错误', 'SYSTEM_ERROR', 'wxPayService', result);
if (retry > 5) {
throw new HttpException('系统错误', HttpStatus.INTERNAL_SERVER_ERROR);
}
await sleep((retry + 1) * 1000);
return await this.sendRedPacket(
openId,
transAmount,
outBizNo,
(retry = retry + 1),
);
} else {
Logger.error('系统错误', 'wxPayService', result);
return null;
}
}
}
View on GitHub (pinned to d3aa8bea5b)
Solutions
- Inspect the logged `result` payload (Logger.error includes it) for the upstream error detail
- Increase retry count or backoff if the outage is expected to be transient
- Verify WeChat Pay merchant config (mchid, API certs, red-packet product enabled, balance)
- Add a circuit breaker so repeated SYSTEM_ERROR fails fast instead of retrying 5 times
- Surface a user-facing message distinct from generic '系统错误' when retries are exhausted
Example fix
// before
if (retry > 5) {
throw new HttpException('系统错误', HttpStatus.INTERNAL_SERVER_ERROR);
}
// after
if (retry > 5) {
Logger.error(`sendRedPacket failed after ${retry} retries`, JSON.stringify(result), 'wxPayService');
throw new HttpException('微信红包发送失败,请稍后重试或联系客服', HttpStatus.BAD_GATEWAY);
} Defensive patterns
Strategy: retry
Validate before calling
if (!openId || !transAmount || transAmount <= 0) {
throw new Error('sendRedPacket requires openId and a positive transAmount');
} Try / catch
try {
return await wxPayService.sendRedPacket(openId, amount, outBizNo);
} catch (err) {
if (err instanceof HttpException && err.getStatus() === 500) {
// check outBizNo for duplicate before manual retry to avoid double payout
}
throw err;
} Prevention
- Keep outBizNo idempotent so manual retries never double-pay
- Verify WeChat merchant config and balance before sending red packets
- Cap retry attempts with exponential backoff and alert on exhaustion
- Monitor upstream 500 rates and trip a circuit breaker
When it happens
Trigger: Calling sendRedPacket when the upstream WeChat/relay API responds { error: 'SYSTEM_ERROR', status: 500 } for more than 5 consecutive retries (retry counter > 5).
Common situations: WeChat Pay merchant-side outage; invalid or unbound merchant configuration for red packets; insufficient merchant balance; upstream relay service degraded — all causing persistent 500s instead of transient ones.
Related errors
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/f4a3b22709a263be.
Report an issue: GitHub.