wechaty / wechaty-puppet-padplus

DEPRECATED: One puppet based on iPad protocal for Wechaty
https://wechaty.js.org/docs/puppet-services/
317 stars 65 forks source link

UnhandledPromiseRejectionWarning: Error: cannot get user_name from raw payload #309

Closed suntong closed 3 years ago

suntong commented 4 years ago

0. Report Issue Guide

  1. Please run the following command and check whether the problem has been fixed:
npm install wechaty-puppet-padlus@next

Not fixed.

  1. Please search in the issue first, and make sure your problem had not been reported before

Not reported before.

1. Versions

npm ls wechaty wechaty-puppet wechaty-puppet-mock wechaty-puppet-padplus
wechaty-getting-started@0.1.20 /path/to/wechaty-examples
├─┬ wechaty@0.48.10 
│ └── UNMET PEER DEPENDENCY wechaty-puppet@0.32.3  deduped
├── UNMET PEER DEPENDENCY wechaty-puppet@0.32.3 
├── wechaty-puppet-mock@0.28.1 
└─┬ wechaty-puppet-padplus@0.7.40 
  └─┬ wechaty-puppet-cache@0.1.10
    └── wechaty-puppet@0.24.0 
$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:    20.04
Codename:   focal

2. Describe the bug

Recently I'm getting the following errors when running with wechaty-puppet-padplus:

(node:69429) UnhandledPromiseRejectionWarning: Error: cannot get user_name from raw payload: {"alias":"","bigHeadUrl":"http://wx.qlogo.cn/mmcrhead/.../0","chatRoomOwner":"wxid_5j...w12","chatroomId":"60..940@chatroom","chatroomVersion":700003494,"contactType":"","memberCount":498,"members":[{"UserName":"wxid_5j..lw12","Wxid":"wxid_5j..lw12","Tag8":0,"MemberContactFlag":1,"NickName":"xxx"},{"UserName":"wxid_81er...c22","Wxid":...,{"UserName":"wxid_8k...m22","Wxid":"wxid_8k...m22","Tag8":0,"MemberContactFlag":1,"NickName":"xx."},{"UserName":"xx","Wxid":"xx","Tag8":0,"MemberContactFlag":1,"NickName":"xx"}],"nickName":"xx️"ÿ,"smallHeadUrl":"http://wx.qlogo.cn/mmcrhead/.../0","stranger":"v1_...@stranger","tagList":"","ticket":""} at Object.contactRawPayloadParser (/path/to/node_modules/wechaty-puppet-padplus/dist/src/pure-function-helpers/contact-raw-payload-parser.js:31:15) at PuppetPadplus.<anonymous> (/path/to/node_modules/wechaty-puppet-padplus/dist/src/puppet-padplus.js:379:58) at Generator.next (<anonymous>) at /path/to/node_modules/wechaty-puppet-padplus/dist/src/puppet-padplus.js:8:71 at new Promise (<anonymous>) at __awaiter (/path/to/node_modules/wechaty-puppet-padplus/dist/src/puppet-padplus.js:4:12) at PuppetPadplus.contactRawPayloadParser (/path/to/node_modules/wechaty-puppet-padplus/dist/src/puppet-padplus.js:377:16) at PuppetPadplus.<anonymous> (/path/to/node_modules/wechaty-puppet/dist/src/puppet.js:473:40) at Generator.next (<anonymous>) at fulfilled (/path/to/node_modules/wechaty-puppet/dist/src/pupp at Page.goto (/path/to/node_modules/puppeteer/lib/Page.js:553:53) at Page.<anonymous> (/path/to/node_modules/puppeteer/lib/helper.remote: Total 5 (delta 3), reused 0 (delta 0) Unpacking objects: 100% (5/5), done. et.js:5:58) (node:69429) 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)

It has happened several times now, and it seems to be all happening to big groups that I joined, like the one above. I.e., all of them are around 500 users.

3. To Reproduce

Steps to reproduce the behavior:

  1. make sure to start with a personal account that has many big groups that are close to 500 users.
  2. run the ding-dong-bot.js from https://github.com/wechaty/wechaty-getting-started/ with wechaty-puppet-padplus as the puppet
  3. then wait for the error to happen, when PuppetPadplus.contactRawPayloadParser is somehow invoked. See wechaty-puppet-padplus/dist/src/pure-function-helpers/contact-raw-payload-parser.js:31:15 and wechaty-puppet-padplus/dist/src/puppet-padplus.js:377:16, and Generator.next at puppet-padplus.js:8:71.

4. Expected behavior

Not seeing such error, as it had been before.

5. Actual behavior

I'm getting such errors recently.

6. Full Output Logs

As above.

7. Additional context

If you take a closer look at the json string, there is an extra "ÿ" before "smallHeadUrl": that is outside of string quote:

{"UserName":"xx","Wxid":"xx","Tag8":0,"MemberContactFlag":1,"NickName":"xx"}],"nickName":"xx️"ÿ,"smallHeadUrl":"http://wx.qlogo.cn/mmcrhead/.../0","stranger":"v1_...@stranger","tagList":"","ticket":""}

This might be the reason for the parser to fail, as that extra "ÿ" should not be there, or at least within the quote ". However, this might well just be an output glitch, so I'm only pointing it out here, in hope it might help.

[bug]

su-chang commented 4 years ago

{"UserName":"xx","Wxid":"xx","Tag8":0,"MemberContactFlag":1,"NickName":"xx"}],"nickName":"xx️"ÿ,"smallHeadUrl":"http://wx.qlogo.cn/mmcrhead/.../0","stranger":"v1_...@stranger","tagList":"","ticket":""}

Do you know what's this ÿ, in the log which you provided?

Can you reproduce it always? It seem that contactRawPayloadParser accepted a room parameter.

suntong commented 4 years ago

Yeah, it is reproducible to me -- I'm getting it all the times.

And in deed that ÿ seems to be the problem. Here is another one that I got, and it contains that ÿ too:

{"UserName":"H..vi","Wxid":"H..vi","Tag8":0,"MemberContactFlag":1,"NickName":"Viv..⚈้̤͡ ˌ̫̮ ⚈้̤"ÿ},{"UserName":"kev...

It seem that contactRawPayloadParser accepted a room parameter

where can I find the API for the contactRawPayloadParser. I know which groups I'm in is causing the problem. I want to see if manually triggering it would cause the same problem too.

su-chang commented 4 years ago

where can I find the API for the contactRawPayloadParser.

You can get detail from the source code.

suntong commented 4 years ago

The exception of Object.contactRawPayloadParser is at (/path/to/node_modules/wechaty-puppet-padplus/dist/src/pure-function-helpers/contact-raw-payload-parser.js:31:15), while the .ts source line 31 is --

https://github.com/wechaty/wechaty-puppet-padplus/blob/4fdaa4500d257decf080ebfbb75430bbcd7ea73e/src/pure-function-helpers/contact-raw-payload-parser.ts#L31

I.e., the # 1 reason I hate .ts is that when you have an exception like this, you'd have no idea where it comes from.

Anyway, I believe the UnhandledPromiseRejectionWarning is coming from this line:

https://github.com/wechaty/wechaty-puppet-padplus/blob/4fdaa4500d257decf080ebfbb75430bbcd7ea73e/src/pure-function-helpers/contact-raw-payload-parser.ts#L18

will probe further to see if I can trigger that call myself...

thx!

suntong commented 4 years ago

And in deed that ÿ seems to be the problem.

No! Find a group info that is perfectly valid (passed through the strict validation perfectly), but I'm still getting the UnhandledPromiseRejectionWarning, with the exact same error messages.

So there is still something wrong with the Object.contactRawPayloadParser, even with correct Payload.

tomallv commented 4 years ago

The same issue was met here, but i found that this worked correctly with wechaty(0.46.4) & wechaty-puppet-padplus(0.6.5). After updating to wechaty(0.48.10) & wechaty-puppet-padplus(0.6.6), this issue occurs.

Follow your talking, just add print command to see what's difference between these two version about the rawPayload in contact-raw-payload-parser.js image

then i found the difference, this rawPayload should be invitee‘s info, but this was instead by the room's info in wechaty-puppet-padplus(0.6.6) image

So far i do not find out which codes are wrong, just sync what i found firstly

su-chang commented 3 years ago

@suntong @tomallv Thank you for your issue.

wechaty-puppet-padplus@0.7.41 could resolve this problem. Please check it again, if there's no question about it, please feel free to close this issue. Thank you very much.

suntong commented 3 years ago

Thanks a lot working towards fixing it. I can't verify it now, but maybe 2 weeks later. Closing it now (and will reopen if something went wrong down the road)

Thanks again!