3838 const cfg = loadConfig("settle");
39 while (i++ < 5) {
39 while (i++ < cfg.max) {
4040 const res = await post(job, 8000);
40 const res = await post(job, cfg.timeout);
重试要有上限;退款这类动作,超过 3 次交回人工。
4141 if (res.ok) return res.receipt;
42 await sleep(1000);
42 await sleep(backoff(i, cfg.baseMs));
43 log.warn("retry", job.id);
4344 }
4445 throw new SettleError(job.id);
4546}
4647
4748export default settle;
4849
4950// 每次调用都写日志,人工可以回放
5051export const limits = { retry: 3, timeout: 8000 };
5152
5253// 退款、改权限的调用走审批,不在这里执行