puppet-wechat
puppet-wechat copied to clipboard
a PR about issue #230
I am using wechaty on my Mac Pc and I run into the error below.
16:52:32 ERR PuppetWeChatBridge start() exception: TimeoutError: Navigation timeout of 60000 ms exceeded
16:52:32 SILL StateSwitch <PuppetWeChatBridge> inactive() is false
16:52:32 VERB StateSwitch <PuppetWeChatBridge> inactive(true) <- (false)
16:52:32 ERR PuppetWeChat initBridge() exception: Navigation timeout of 60000 ms exceeded
16:52:32 VERB PuppetWeChatBridge stop()
16:52:32 SILL StateSwitch <PuppetWeChatBridge> inactive() is true
16:52:32 VERB StateSwitch <PuppetWeChatBridge> inactive(pending) <- (true)
16:52:32 WARN PuppetWeChatBridge stop() page.close() exception: Error: Protocol error: Connection closed. Most likely the page has been closed.
16:52:32 SILL PuppetWeChatBridge stop() browser.close()-ed
16:52:32 SILL StateSwitch <PuppetWeChatBridge> inactive() is pending
16:52:32 VERB StateSwitch <PuppetWeChatBridge> inactive(true) <- (pending)
I have checked the issues and find https://github.com/wechaty/puppet-wechat/issues/230 has the same situation. So I analyzed the start process of this puppet, and I assume the polling request on wx.qq.com prevents the page.goto() from reaching the 'load' state. I tested myself by using puppeteer to open 'wx.qq.com' and the page cannot reach the state of 'load'.
As a result, I tried to modify two parts of the code Bridge.ts about the waiting state of the Puppeteer.Page of opening the url 'wx.qq.com'. And it works.
[!IMPORTANT] Fix navigation timeout in
PuppetWeChatBridgeby usingnetworkidle2and changing load event listener todomcontentloadedinbridge.ts.
- Behavior:
- Fix navigation timeout in
initPage()inbridge.tsby settingwaitUntil: 'networkidle2'inpage.goto().- Change page load event listener from
loadtodomcontentloadedininitPage()to handle polling requests onwx.qq.com.This description was created by
for 9e4df4f0f1a8ea5c9710e2078f1349c61486826d. It will automatically update as commits are pushed.
Summary by CodeRabbit
- New Features
- Improved page loading behavior by ensuring navigation waits for the network to be idle.
- Updated event listener to respond to the
domcontentloadedevent for better control during page initialization.