Commit 75b4ec1d by Jaxon

fix(libs/interval): 修复轮询错误时未清理定时器的问题

1 parent eaca37ac
...@@ -27,6 +27,9 @@ export function startPolling(requestFn, interval = 3000, stopCondition = () => f ...@@ -27,6 +27,9 @@ export function startPolling(requestFn, interval = 3000, stopCondition = () => f
} catch (error) { } catch (error) {
console.error("轮询请求发生错误:", error); console.error("轮询请求发生错误:", error);
// 发生错误时默认继续轮询,如果需要错误时停止,可以在 stopCondition 中处理,或者在这里加配置 // 发生错误时默认继续轮询,如果需要错误时停止,可以在 stopCondition 中处理,或者在这里加配置
if (timer) {
clearTimeout(timer);
}
} }
// 安排下一次执行 // 安排下一次执行
if (!isStopped) { if (!isStopped) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!