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

WXGetContact cannot get user_name #1358

Closed
huan opened this Issue Jun 17, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@huan
Copy link
Member

huan commented Jun 17, 2018

6061139518@chatroom is a Chatroom that the bot was invited into it before, but had been removed out later.

16:42:13 WARN PadchatRpc WXGetContact cannot get user_name, id: 6061139518@chatroom, "{"big_head":"","city":"","country":"","intro":"","label":"","message":"","nick_name":"","provincia":"","py_initial":"","quan_pin":"","remark":"","remark_py_initial":"","remark_quan_pin":"","sex":0,"signature":"","small_head":"","status":0,"stranger":"","ticket":"","user_name":""}"
(node:66580) UnhandledPromiseRejectionWarning: Error: tryRawPayload empty
    at PadchatManager.<anonymous> (/home/zixia/chatie/wechaty/src/puppet-padchat/padchat-manager.ts:958:20)
    at Generator.next (<anonymous>)
    at fulfilled (/home/zixia/chatie/wechaty/src/puppet-padchat/padchat-manager.ts:4:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:66580) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 9)
16:42:13 WARN PadchatRpc WXGetContact cannot get user_name, id: 6061139518@chatroom, "{"big_head":"","city":"","country":"","intro":"","label":"","message":"","nick_name":"","provincia":"","py_initial":"","quan_pin":"","remark":"","remark_py_initial":"","remark_quan_pin":"","sex":0,"signature":"","small_head":"","status":0,"stranger":"","ticket":"","user_name":""}"
(node:66580) UnhandledPromiseRejectionWarning: Error: tryRawPayload empty
    at PadchatManager.<anonymous> (/home/zixia/chatie/wechaty/src/puppet-padchat/padchat-manager.ts:958:20)
    at Generator.next (<anonymous>)
    at fulfilled (/home/zixia/chatie/wechaty/src/puppet-padchat/padchat-manager.ts:4:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:66580) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 10)

@huan huan added the bug label Jun 17, 2018

@lijiarui

This comment has been minimized.

Copy link
Member

lijiarui commented Jun 22, 2018

I found this issue here, in padchat-manager.ts

public async contactRawPayload(contactId: string): Promise<PadchatContactPayload> {
    log.silly('PuppetPadchatManager', 'contactRawPayload(%s)', contactId)

    const rawPayload = await Misc.retry(async (retry, attempt) => {
      log.silly('PuppetPadchatManager', 'contactRawPayload(%s) retry() attempt=%d', contactId, attempt)

      if (!this.cacheContactRawPayload) {
        throw new Error('no cache')
      }

      if (this.cacheContactRawPayload.has(contactId)) {
        return this.cacheContactRawPayload.get(contactId)
      }

-   const tryRawPayload =  await this.WXGetContactPayload(contactId)
+   const tryRawPayload =  await this.WXSearchContactPayload(contactId)

      // check user_name too becasue the server might return {}
      // See issue #1358 https://github.com/Chatie/wechaty/issues/1358
      if (tryRawPayload /* && tryRawPayload.user_name */) {
        this.cacheContactRawPayload.set(contactId, tryRawPayload)
        return tryRawPayload
      }
      return retry(new Error('tryRawPayload empty'))
    })

    if (!rawPayload) {
      throw new Error('no raw payload')
    }
    return rawPayload
  }

I think maybe we should change WXGetContactPayload to WXSearchContactPayload. Because WXGetContactPayload only works when the contact has friendship with the bot.

see more:


Also, when I syncContact the the strange error, I think this relate to the WXGetContact

00:23:58 WARN PadchatRpc WXGetContact cannot get user_name, id: lizhuohuan, "{}"
00:23:58 ERR Contact ready() this.puppet.contactPayload(Contact) exception: cannot get user_name from raw payload: {}
(node:74322) UnhandledPromiseRejectionWarning: Error: cannot get user_name from raw payload: {}
    at Object.contactRawPayloadParser (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/pure-function-helpers/contact-raw-payload-parser.ts:42:11)
    at PuppetPadchat.<anonymous> (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:700:37)
    at Generator.next (<anonymous>)
    at /Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:25:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:21:12)
    at PuppetPadchat.contactRawPayloadParser (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:522:16)
    at PuppetPadchat.<anonymous> (/Users/jiaruili/git/rui/wechaty/src/puppet/puppet.ts:494:35)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/jiaruili/git/rui/wechaty/src/puppet/puppet.ts:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
(node:74322) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 54)
{}
00:23:59 WARN PadchatRpc WXGetContact cannot get user_name, id: lizhuohuan, "{}"
00:23:59 ERR Contact ready() this.puppet.contactPayload(Contact) exception: cannot get user_name from raw payload: {}
(node:74322) UnhandledPromiseRejectionWarning: Error: cannot get user_name from raw payload: {}
    at Object.contactRawPayloadParser (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/pure-function-helpers/contact-raw-payload-parser.ts:42:11)
    at PuppetPadchat.<anonymous> (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:700:37)
    at Generator.next (<anonymous>)
    at /Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:25:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:21:12)
    at PuppetPadchat.contactRawPayloadParser (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:522:16)
    at PuppetPadchat.<anonymous> (/Users/jiaruili/git/rui/wechaty/src/puppet/puppet.ts:494:35)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/jiaruili/git/rui/wechaty/src/puppet/puppet.ts:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
(node:74322) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 56)
{}
00:23:59 WARN PadchatRpc WXGetContact cannot get user_name, id: lizhuohuan, "{}"
00:23:59 ERR Contact ready() this.puppet.contactPayload(Contact) exception: cannot get user_name from raw payload: {}
(node:74322) UnhandledPromiseRejectionWarning: Error: cannot get user_name from raw payload: {}
    at Object.contactRawPayloadParser (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/pure-function-helpers/contact-raw-payload-parser.ts:42:11)
    at PuppetPadchat.<anonymous> (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:700:37)
    at Generator.next (<anonymous>)
    at /Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:25:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:21:12)
    at PuppetPadchat.contactRawPayloadParser (/Users/jiaruili/git/rui/wechaty/src/puppet-padchat/puppet-padchat.ts:522:16)
    at PuppetPadchat.<anonymous> (/Users/jiaruili/git/rui/wechaty/src/puppet/puppet.ts:494:35)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/jiaruili/git/rui/wechaty/src/puppet/puppet.ts:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
(node:74322) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 58)
@huan

This comment has been minimized.

Copy link
Member

huan commented Jul 3, 2018

Close this issue because it will continue discussing on its own repo.

@huan huan closed this Jul 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment