From 9e4df4f0f1a8ea5c9710e2078f1349c61486826d Mon Sep 17 00:00:00 2001 From: zinsser <576134494@qq.com> Date: Thu, 26 Dec 2024 16:53:55 +0800 Subject: [PATCH] https://github.com/wechaty/puppet-wechat/issues/230, The polling request on wx.qq.com prevents the page.goto() from reaching the load state, because there is a continuous polling request to the server. Therefore, we need to modify the wait state when navigating to the page. --- src/bridge.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bridge.ts b/src/bridge.ts index ab25ebf..1da20cf 100644 --- a/src/bridge.ts +++ b/src/bridge.ts @@ -252,7 +252,10 @@ export class Bridge extends EventEmitter { // set timeout 60000 ms,30000ms always timeout page.setDefaultTimeout(60000) // Does this related to(?) the CI Error: exception: Navigation Timeout Exceeded: 30000ms exceeded - await page.goto(url) + await page.goto(url, { + //The polling request on wx.qq.com prevents the page.goto() from reaching the 'load' state, so we use networkidle2 to wait for the page to be fully loaded. + waitUntil: 'networkidle2', + }) log.verbose('PuppetWeChatBridge', 'initPage() after page.goto(url)') // await this.uosPatch(page) @@ -263,7 +266,9 @@ export class Bridge extends EventEmitter { log.silly('PuppetWeChatBridge', 'initPage() page.setCookie() %s cookies set back', cookieList.length) } - page.on('load', () => this.emit('load', page)) + //page.on('load', () => this.emit('load', page)) + //due to polling request on wx.qq.com + page.on('domcontentloaded', () => this.emit('load', page)) await page.reload() // reload page to make effect of the new cookie. return page