SuperMonster003 / AutoJs6

安卓平台 JavaScript 自动化工具 (Auto.js 二次开发项目)
https://docs.autojs6.com
Mozilla Public License 2.0
2.42k stars 715 forks source link

Can not use Timer(setTimeout/setInterval/...) in websocket #80

Open anhnhoktvn opened 1 year ago

anhnhoktvn commented 1 year ago
let ws = web.newWebSocket('wss://echo.websocket.events')

setImmediate(() => {
  console.log('This is fine')
})

ws.on('open', (res, ws) => {
  setImmediate(() => {
    console.log('This is error<-----------')
  })

})
setTimeout(() => {
  ws.close(1000, 'Closed by user')
}, 8e3)

Error log:

 Wrapped java.lang.NullPointerException: Attempt to invoke virtual method 'int org.autojs.autojs.core.looper.Timer.setImmediate(java.lang.Object, java.lang.Object[])' on a null object reference ($remote/main2.js#8)
Wrapped java.lang.NullPointerException: Attempt to invoke virtual method 'int org.autojs.autojs.core.looper.Timer.setImmediate(java.lang.Object, java.lang.Object[])' on a null object reference
SuperMonster003 commented 1 year ago

Thank you for the feedback, but I can't reproduce the bug reported above.

Have you tried out the latest version of both AutoJs6 and its VSCode extension?

anhnhoktvn commented 1 year ago

I've tried on the latest version v6.3.3, still got that errror

3 4