wechaty / puppet-wechat

Wechaty Puppet Provider for WeChat
https://www.npmjs.com/package/wechaty-puppet-wechat
Apache License 2.0
405 stars 67 forks source link

BUG: Protocol error and GError in latest version #203

Closed shangdev closed 2 years ago

shangdev commented 2 years ago

升级到最新版本后,经常出现以下错误

  "dependencies": {
    "form-data": "^4.0.0",
    "isomorphic-fetch": "^3.0.0",
    "wechaty": "^1.10.4",
    "wechaty-puppet-wechat": "^1.11.11"
  },

Error 1: WARN PuppetWeChatBridge proxyWechaty() noWechaty exception: Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.

Error 2: WeChaty发生错误: GError: from(object): {"gerror":"{\"code\":2,\"details\":\"Error: WatchdogAgent reset: lastFood: \\\"{\\\"data\\\":\\\"heartbeat@browserbridge ding\\\",\\\"timeoutMilliseconds\\\":60000}\\\"\\n at Watchdog.reset (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty-puppet/dist/esm/src/agents/watchdog-agent.js:45:39)\\n at Watchdog.emit (node:events:390:28)\\n at Timeout._onTimeout (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/watchdog/dist/esm/src/watchdog.js:81:18)\\n at listOnTimeout (node:internal/timers:557:17)\\n at processTimers (node:internal/timers:500:7)\",\"message\":\"WatchdogAgent reset: lastFood: \\\"{\\\"data\\\":\\\"heartbeat@browserbridge ding\\\",\\\"timeoutMilliseconds\\\":60000}\\\"\",\"name\":\"Error\",\"stack\":\"Error: WatchdogAgent reset: lastFood: \\\"{\\\"data\\\":\\\"heartbeat@browserbridge ding\\\",\\\"timeoutMilliseconds\\\":60000}\\\"\\n at Watchdog.reset (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty-puppet/dist/esm/src/agents/watchdog-agent.js:45:39)\\n at Watchdog.emit (node:events:390:28)\\n at Timeout._onTimeout (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/watchdog/dist/esm/src/watchdog.js:81:18)\\n at listOnTimeout (node:internal/timers:557:17)\\n at processTimers (node:internal/timers:500:7)\"}"}

此时Wechaty已奔溃无法运行,ctrl + c 退出后重新 npm start 开始运行项目,自动登录成功。

huan commented 2 years ago

Could you please try the next version and see what the error message is?

npm install wechaty-puppet-wechat@next
shangdev commented 2 years ago

@huan

It is already the latest version.

├── form-data@4.0.0
├── isomorphic-fetch@3.0.0
├── wechaty-puppet-wechat@1.11.12
└── wechaty@1.11.42

This is the latest error message

15:43:09 WARN PuppetWatchdogAgent start() reset() reason: {"data":"heartbeat@browserbridge ding","timeoutMilliseconds":60000}
GError: WatchdogAgent reset: lastFood: "{"data":"heartbeat@browserbridge ding","timeoutMilliseconds":60000}"
    at Watchdog.reset (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty-puppet/dist/esm/src/agents/watchdog-agent.js:45:39)
    at Watchdog.emit (node:events:390:28)
    at Timeout._onTimeout (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/watchdog/dist/esm/src/watchdog.js:81:18)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7) {
  code: 2,
  details: 'Error: WatchdogAgent reset: lastFood: "{"data":"heartbeat@browserbridge ding","timeoutMilliseconds":60000}"\n' +
    '    at Watchdog.reset (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty-puppet/dist/esm/src/agents/watchdog-agent.js:45:39)\n' +
    '    at Watchdog.emit (node:events:390:28)\n' +
    '    at Timeout._onTimeout (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/watchdog/dist/esm/src/watchdog.js:81:18)\n' +
    '    at listOnTimeout (node:internal/timers:557:17)\n' +
    '    at processTimers (node:internal/timers:500:7)'
}
huan commented 2 years ago

It seems that your puppeteer has crashed, which caused it to fail to emit heartbeats, meanwhile, the watchdog has to reset the puppet after 60 seconds.

How much memory do you have on the machine that the bot running on?

shangdev commented 2 years ago

Total 8g, available 2g

huan commented 2 years ago

Ideally, the watchdog should reset the puppet, and the puppet should be able to restart itself like a fresh start, which can recover your bot session.

However, it seems that in your case, the reset failed.

Need to be investigated, and please keep updating if you have more information valuable to provide.

Thank you very much.

shangdev commented 2 years ago

@huan

发现这几天网页版微信好像有问题,在 Chrome 上登录也是,总是收到一堆乱码消息

以下为网页tab块 image

以下实际是一个表情 image

以下实际是语音消息 image

不知道这个和此BUG有关系没、

huan commented 2 years ago

If the Web WeChat itself has problems, then our RPA-ed puppeteer program would be easily crashed with any unexpected behaviors.

shangdev commented 2 years ago

@huan

最近2天,一直出现以下错误:No Url

` 16:20:23 WARN PuppetWeChat ready() exception: no Url file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty-puppet-wechat/dist/esm/src/puppet-wechat.js:879 throw new Error('no Url'); ^

Error: no Url at PuppetWeChat.messageRawPayloadToUrl (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty-puppet-wechat/dist/esm/src/puppet-wechat.js:879:39) at PuppetWeChat.messageRawPayloadToFile (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty-puppet-wechat/dist/esm/src/puppet-wechat.js:236:32) at PuppetWeChat.messageFile (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty-puppet-wechat/dist/esm/src/puppet-wechat.js:225:36) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async WechatifiedUserClass.toFileBox (file:///data/wwwroot/BWK_WechatWebBot_JS/node_modules/wechaty/dist/esm/src/user-modules/message.js:764:25) at async WechatyImpl.onMessage (file:///data/wwwroot/BWK_WechatWebBot_JS/index.js:58:21) `

请问这个是什么引起的?

huan commented 2 years ago

I have no idea about this problem.

Can you provide a reproducible steps with related code?