MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / watchPaymentOpTask

Function watchPaymentOpTask

static/js/payment.js:143–166  ·  view source on GitHub ↗
(taskId, onUpdate, maxWaitMs = 20 * 60 * 1000)

Source from the content-addressed store, hash-verified

141}
142
143async function watchPaymentOpTask(taskId, onUpdate, maxWaitMs = 20 * 60 * 1000) {
144 const startedAt = Date.now();
145 while (Date.now() - startedAt < maxWaitMs) {
146 const task = await api.get(`/payment/ops/tasks/${taskId}`, {
147 timeoutMs: 30000,
148 retry: 0,
149 requestKey: `payment:op-task:${taskId}`,
150 cancelPrevious: true,
151 });
152
153 if (typeof onUpdate === "function") {
154 onUpdate(task);
155 }
156
157 const status = String(task?.status || "").toLowerCase();
158 if (["completed", "failed", "cancelled"].includes(status)) {
159 return task;
160 }
161
162 await sleep(1200);
163 }
164
165 throw new Error("支付任务等待超时,请稍后重试");
166}
167
168function escapeHtml(value) {
169 const div = document.createElement("div");

Callers 1

Calls 2

sleepFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected