一个electron项目,在使用setInterval轮询时,出现了网络崩溃的系统错误。 在setInterval中执行console.log显示setInterval还会执行,但是axios不会重新发起ajax请求。其中getControlStatus轮询后端接口获取数据
renderer.js:1 Uncaught (in promise) SystemError [ERR_SYSTEM_ERROR]: A system error occurred: undefined returned undefined (undefined)
at Object.networkInterfaces (os.js:203)
at t.default (renderer.js:12)
at a.<anonymous> (renderer.js:26)
at r (renderer.js:26)
at Generator._invoke (renderer.js:26)
at Generator.forEach.e.<computed> [as next] (renderer.js:26)
at i (renderer.js:1)
at renderer.js:1
at new Promise (<anonymous>)
at new t (renderer.js:12)
addCodeToName @ internal/errors.js:306
SystemError @ internal/errors.js:165
NodeError @ internal/errors.js:250
checkError @ os.js:64
hidden @ internal/errors.js:294
networkInterfaces @ os.js:203
t.default @ renderer.js:12
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval (async)
resetControlStatusRequest @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
handleControlOrder @ renderer.js:26
(anonymous) @ renderer.js:26
r @ renderer.js:26
(anonymous) @ renderer.js:26
forEach.e.<computed> @ renderer.js:26
i @ renderer.js:1
(anonymous) @ renderer.js:1
Promise.then (async)
i @ renderer.js:1
(anonymous) @ renderer.js:1
t @ renderer.js:12
(anonymous) @ renderer.js:1
getControlStatus @ renderer.js:26
(anonymous) @ renderer.js:26
setInterval存在的问题
对自己调用的代码是否报错会无视掉。即自己调用的代码即使错误,也会继续执行下去,这就是导致上述问题获取接口失效原因。
setInterval无视网络延迟
我们在向服务器轮询数据的时候,如果发生网络卡顿的情况,客户端收到请求响应的时间大于interval循环的时间。而setInterval会无视任何情况下继续定时执行,这就会导致了用户的客户端里充斥着客户端的请求
参考文章