Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebDriverError: unknown error: r.isBrandContact is not a function #81

Closed
huan opened this issue Nov 8, 2016 · 12 comments
Closed

WebDriverError: unknown error: r.isBrandContact is not a function #81

huan opened this issue Nov 8, 2016 · 12 comments

Comments

@huan
Copy link
Member

huan commented Nov 8, 2016

A strange bug: ( with docker image v0.5.1 & v0.5.9 )

Today, a wechaty runtime run ok at the start, but after 2-3 hours, it can not accept friend request anymore. after a while, it can accept the friend request, but can not send any message.

switch from v0.5.1 to v0.5.9 still has this issue.

After turn on the log, it was found that when call WechatyBro.send(), it shows the follow exception: (I guess the FriendRequest.accept() has the similar exception before)

At last, after we restarted the runtime serval times again, the bug was gone. All works well again... wired...

Maybe it's because the Angular environment is not inited right?

To debug...

WARN PuppetWebBrowser execute() exception: unknown error: r.isBrandContact is not a function
  (Session info: chrome=53.0.2785.92)
  (Driver i, WebDriverError: unknown error: r.isBrandContact is not a function
  (Session info: chrome=53.0.2785.92)
  (Driver info: chromedriver=2.22 (5e2d5494d735a71aa5c2e7ef9bf5ce96945e92e9),platform=Linux 3.16.0-4-amd64 x86_64)
    at WebDriverError (/wechaty/node_modules/selenium-webdriver/lib/error.js:27:5)
    at Object.checkLegacyResponse (/wechaty/node_modules/selenium-webdriver/lib/error.js:505:15)
    at parseHttpResponse (/wechaty/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/wechaty/node_modules/selenium-webdriver/lib/http.js:440:13)
    at process._tickDomainCallback (internal/process/next_tick.js:129:7)
From: Task: WebDriver.executeScript()
    at Driver.schedule (/wechaty/node_modules/selenium-webdriver/lib/webdriver.js:815:17)
    at Driver.executeScript (/wechaty/node_modules/selenium-webdriver/lib/webdriver.js:886:16)
    at BrowserDriver.executeScript (/wechaty/src/puppet-web/browser-driver.ts:290:66)
    at Browser.<anonymous> (/wechaty/src/puppet-web/browser.ts:269:46)
    at next (native)
    at /wechaty/dist/src/puppet-web/browser.js:7:65
    at __awaiter (/wechaty/dist/src/puppet-web/browser.js:3:12)
    at Browser.execute (/wechaty/dist/src/puppet-web/browser.js:216:16)
    at Bridge.execute (/wechaty/src/puppet-web/bridge.ts:358:32)
    at execute.then.then (/wechaty/src/puppet-web/bridge.ts:344:19)
WARN PuppetWebBridge execute() exception: unknown error: r.isBrandContact is not a function
  (Session info: chrome=53.0.2785.92)
  (Driver info: chromedriver=2.22 (5e2d5494d735a71aa5c2e7ef9bf5ce96945e92e9),platform=Linux 3.16.0-4-amd64 x86_64)
WARN PuppetWebBridge proxyWechaty() exception: unknown error: r.isBrandContact is not a function
  (Session info: chrome=53.0.2785.92)
  (Driver info: chromedriver=2.22 (5e2d5494d735a71aa5c2e7ef9bf5ce96945e92e9),platform=Linux 3.16.0-4-amd64 x86_64)
ERR PuppetWebBridge send() exception: unknown error: r.isBrandContact is not a function
  (Session info: chrome=53.0.2785.92)
  (Driver info: chromedriver=2.22 (5e2d5494d735a71aa5c2e7ef9bf5ce96945e92e9),platform=Linux 3.16.0-4-amd64 x86_64)
ERR PuppetWeb send() exception: unknown error: r.isBrandContact is not a function
  (Session info: chrome=53.0.2785.92)
@huan huan added the bug label Nov 8, 2016
@JasLin
Copy link
Contributor

JasLin commented Nov 11, 2016

BTW: it's good idea to implement isBrandContact to wecahty? :) hha

@huan
Copy link
Member Author

huan commented Nov 11, 2016

Of cause we can. maybe Contact.brand(): boolean is a good API name?

However, the exception in this issue is not inside nodejs, it's inside the browser. I believe it was caused by the bug in wxwebApp.

I set up a tracker on wxwebApp source code yesterday, you can have a look, maybe you will like it:
https://github.com/wechaty/webwx-app-tracker

@JasLin
Copy link
Contributor

JasLin commented Nov 12, 2016

this tool bring me sense of security ;) hha

@JasLin
Copy link
Contributor

JasLin commented Nov 12, 2016

how about:

Contact.brand(filter): Array<Contact>
Contact:isBrand(): boolean

@lijiarui
Copy link
Member

@zixia

as #272 said:

Run npm run doctor or wechaty run doctor(for docker user), paste output here

> [email protected] doctor /wechaty
> npm run check-node-version && ts-node bin/doctor


> [email protected] check-node-version /wechaty
> check-node-version --node ">= 6.9"

node: v7.5.0
npm: v4.1.2

  #### Wechaty Doctor

  1. Wechaty version: 0.7.33
  2. Linux x64 version 3.10.0-514.2.2.el7.x86_64 memory 62/992 MB
  3. Docker: true
  4. Node version: v7.5.0
  5. Tcp IPC TEST: PASS

code as follows:

    public async accept(): Promise<boolean> {
        let result = await this.request.accept()
        if (result) {
            const content = `通过好友申请成功,好友昵称${this.contact.name()},好友请求内容是: ${this.request.hello}`
            log.info(content)
            this.contact.say(Msg.FRIEND_WELCOME)
        }
        else {
            const content = `好友请求通过失败,好友昵称${this.contact.name()},好友请求内容是:${this.request.hello}`
            log.warn(content)
            ServerJiang.notify(content)
        }
        return result
    }

the project here: Click

When I catch this error, I can accept friendrequest, and can execute log.info(content) but cannot excute this.contact.say(Msg.FRIEND_WELCOME), log as follows:

error as follows:

info: 通过好友申请成功,好友昵称金庸,好友请求内容是: 我是金庸
WARN Wechaty user() DEPRECATED. use self() instead.
WARN PuppetWebBrowser execute() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver i, WebDriverError: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
    at Object.checkLegacyResponse (/bot/node_modules/selenium-webdriver/lib/error.js:517:15)
    at parseHttpResponse (/bot/node_modules/selenium-webdriver/lib/http.js:516:11)
    at doSend.then.response (/bot/node_modules/selenium-webdriver/lib/http.js:432:13)
    at process._tickDomainCallback (internal/process/next_tick.js:129:7)
WARN PuppetWebBridge execute() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
WARN PuppetWebBridge proxyWechaty() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
ERR PuppetWebBridge send() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
ERR PuppetWeb send() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
ERR Wechaty send() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
ERR Config ###########################
ERR Config unhandledRejection: WebDriverError: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64) [object Promise]
ERR Config ###########################
ERR Config unhandledRejection::catch(unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64))
(node:21) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)

@lijiarui
Copy link
Member

lijiarui commented Feb 22, 2017

What's more, I have occurred this before, but not that frequently, so I ignored it .

But these days, this error appeared frequently ...

@lijiarui
Copy link
Member

you can run the following code

import {Wechaty} from 'wechaty'

const wechatyRobot = Wechaty.instance({profile: 'test'});

wechatyRobot
    .on('scan', (url, code) => console.log(url))
    .on('login', (user) => console.log(`${user} login`))
    .on('friend', async function (contact, request) {
      if (request){
        let result = await request.accept()
        if (result) {
            const content = `通过好友申请成功,好友昵称${contact.name()},好友请求内容是: ${request.hello}`
            console.log(content)
            contact.say('你好呀,我通过了你的好友请求')
        }
        else {
            const content = `好友请求通过失败,好友昵称${contact.name()}}`
        }
      }
    })
    .init()

@lijiarui
Copy link
Member

lijiarui commented Feb 22, 2017

Reprocude:

  • If one haven't sent request before, then he sent a friend request, it can emit this error.
  • If one have sent request before, the bot delete the contact, then the contact resent a friend request, it cannot emit this error.

Silly log as follows:

SILL Message constructor() SN:0
SILL Message ready()
SILL Contact constructor(fmessage)
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
VERB PuppetWebBridge proxyWechaty(getContact, fmessage)
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof  ... ")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL Contact contactGetter(fmessage) resolved
SILL Contact ready()
VERB PuppetWebFirer fireFriendRequest([object Object])
VERB PuppetWebFriendRequest constructor()
VERB FriendRequest constructor()
VERB PuppetWebFriendRequest receive([object Object])
SILL Contact constructor(@67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce)
SILL Contact ready()
SILL Contact get contact via PuppetWeb
SILL PuppetWebBridge getContact() retryPromise: attampt 1/35 time for timeout 306250
VERB PuppetWebBridge proxyWechaty(getContact, @67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce)
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof  ... ")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL Contact contactGetter(@67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce) resolved
VERB FriendRequest accept() 🍍 小纯婕"
VERB PuppetWebBridge verifyUserOk(@67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce, v2_e8cdc53dabc19a586880c7e2a1ef599c0c2a2de7b76e24dea8046cd801c5c3b306b6dcaad4e9ea4bc450e0d61e88ef6909724f1ac98b36cc651a92361abb909c@stranger)
VERB PuppetWebBridge proxyWechaty(verifyUserOkAsync, @67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce, v2_e8cdc53dabc19a586880c7e2a1ef599c0c2a2de7b76e24dea8046cd801c5c3b306b6dcaad4e9ea4bc450e0d61e88ef6909724f1ac98b36cc651a92361abb909c@stranger)
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL PuppetWebBrowser Browser.executeAsync( const callback = arguments[arguments.length - 1]
      const isAsync = (typeof )
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
VERB PuppetWebEvent onServerLog(friendVerify(@67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce, v2_e8cdc53dabc19a586880c7e2a1ef599c0c2a2de7b76e24dea8046cd801c5c3b306b6dcaad4e9ea4bc450e0d61e88ef6909724f1ac98b36cc651a92361abb909c@stranger) done)
SILL PuppetWebFriendRequest accept() retryPromise() attempt 1 with timeout 60000
SILL Contact ready()
VERB PuppetWebFriendRequest accept() with contact 🍍 小纯婕" ready()
通过好友申请成功,好友昵称🍍 小纯婕",好友请求内容是: 我是🍍 小纯婕"
VERB Contact say(你好呀,我通过了你的好友请求)
WARN Wechaty user() DEPRECATED. use self() instead.
SILL Message constructor() SN:1
SILL Contact say() from: 小桔同学 to: 🍍 小纯婕" content: 你好呀,我通过了你的好友请求
SILL PuppetWeb send() destination: @67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce, content: 你好呀,我通过了你的好友请求)
VERB PuppetWebBridge proxyWechaty(send, @67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce, 你好呀,我通过了你的好友请求)
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute("return typeof WechatyBro === "undefined"")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL PuppetWebBridge execute()
SILL PuppetWebBrowser Browser.execute(" const callback = arguments[arguments.length - 1] const isAsync = (typeof  ... ")
SILL StateMonitor Browser:target() - open
SILL StateMonitor Browser:current() - open
SILL Message constructor() SN:2
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL PuppetWebBrowser execute() script:  const callback = arguments[arguments.length - 1]
      const isAsync = (typeof callback === 'function')
      return WechatyBro
              .send
              .apply(undefined
                      , isAsync
                        ? JSON.parse(decodeURIComponent(window.atob('JTVCJTIyJTQwNjdjOTcxMTFhNjMwN2MxMGVkOTliODg1NzRkMGI0YWNjYTY5Mzg0MTM0YWEwNjAzYmE0NjI4ZTljYmQxYmRjZSUyMiUyQyUyMiVFNCVCRCVBMCVFNSVBNSVCRCVFNSU5MSU4MCVFRiVCQyU4QyVFNiU4OCU5MSVFOSU4MCU5QSVFOCVCRiU4NyVFNCVCQSU4NiVFNCVCRCVBMCVFNyU5QSU4NCVFNSVBNSVCRCVFNSU4RiU4QiVFOCVBRiVCNyVFNiVCMSU4MiUyMiU1RA=='))).concat(callback)
                        : JSON.parse(decodeURIComponent(window.atob('JTVCJTIyJTQwNjdjOTcxMTFhNjMwN2MxMGVkOTliODg1NzRkMGI0YWNjYTY5Mzg0MTM0YWEwNjAzYmE0NjI4ZTljYmQxYmRjZSUyMiUyQyUyMiVFNCVCRCVBMCVFNSVBNSVCRCVFNSU5MSU4MCVFRiVCQyU4QyVFNiU4OCU5MSVFOSU4MCU5QSVFOCVCRiU4NyVFNCVCQSU4NiVFNCVCRCVBMCVFNyU5QSU4NCVFNSVBNSVCRCVFNSU4RiU4QiVFOCVBRiVCNyVFNiVCMSU4MiUyMiU1RA==')))
                    )

WARN PuppetWebBrowser execute() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver i, WebDriverError: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
    at Object.checkLegacyResponse (/bot/node_modules/selenium-webdriver/lib/error.js:517:15)
    at parseHttpResponse (/bot/node_modules/selenium-webdriver/lib/http.js:516:11)
    at doSend.then.response (/bot/node_modules/selenium-webdriver/lib/http.js:432:13)
    at process._tickDomainCallback (internal/process/next_tick.js:129:7)
WARN PuppetWebBridge execute() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
VERB PuppetWebBridge proxyWechaty(send, @67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce, 你好呀,我通过了你的好友请求)
WARN PuppetWebBridge proxyWechaty() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
ERR PuppetWebBridge send() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
ERR PuppetWeb send() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
ERR Wechaty send() exception: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64)
ERR Config ###########################
ERR Config unhandledRejection: WebDriverError: unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64) [object Promise]
ERR Config ###########################
ERR Config unhandledRejection::catch(unknown error: o.isBrandContact is not a function
  (Session info: chrome=56.0.2924.76)
  (Driver info: chromedriver=2.25 (5a911c1ac99b36efadff2041357740080cc27220),platform=Linux 3.10.0-514.2.2.el7.x86_64 x86_64))
(node:21) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
SILL Message constructor() SN:3
SILL Message ready()
SILL Contact ready()
SILL Contact ready()
SILL PuppetWebFirer fireFriendConfirm(你已添加了🍍 小纯婕",现在可以开始聊天了。)
VERB PuppetWebFriendRequest constructor()
VERB FriendRequest constructor()
VERB PuppetWebFriendRequest confirm(🍍 小纯婕")
SILL Contact ready()
SILL Message ready()
SILL Contact ready()
SILL Contact ready()

@huan
Copy link
Member Author

huan commented Feb 22, 2017

The runnable code snip and the clear log helps a lot to identify this issue.

According to the log:

VERB PuppetWebBridge proxyWechaty(send, @67c97111a6307c10ed99b88574d0b4acca69384134aa0603ba4628e9cbd1bdce, 你好呀,我通过了你的好友请求)

Wechaty is passing the send message parameters to the browser in function here:
47d81b6#diff-4918585f06a4ef33203ba29b9b63d1d8R423

Which cause a exception in browser at here:
wechaty/webwx-app-tracker@e413c1d#diff-80c9da80c8ca080b37c6c49864880646L2289

I'm not clear why this could happen, let's continue keeping eyes on this issue.

@xinbenlv
Copy link
Contributor

xinbenlv commented Apr 3, 2017

1, also happens to me(a lot)

@huan
Copy link
Member Author

huan commented May 5, 2017

This is an old bug.

As far as I know: this exception does not occur at node side.

It's an exception inside browser, so it should be caused by https://github.com/Chatie/wechaty/blob/master/src/puppet-web/wechaty-bro.js

@huan
Copy link
Member Author

huan commented Aug 18, 2017

Long time no see...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants