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

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

Closed
suntong opened this issue Sep 5, 2020 · 8 comments

Comments

@suntong
Copy link

suntong commented Sep 5, 2020

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

  • What is your wechaty version?
  • What is your wechaty-puppet-XXX(padchat/puppeteer/) version?
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 
  • What is your node version? (run node --version)
    Answer: v10.21.0

  • What os are you using
    Answer:

$ 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
Copy link
Member

su-chang commented Sep 7, 2020

{"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
Copy link
Author

suntong commented Sep 7, 2020

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
Copy link
Member

su-chang commented Sep 7, 2020

where can I find the API for the contactRawPayloadParser.

You can get detail from the source code.

@suntong
Copy link
Author

suntong commented Sep 7, 2020

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 --

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:

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

thx!

@suntong
Copy link
Author

suntong commented Sep 7, 2020

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
Copy link

tomallv commented Sep 28, 2020

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
Copy link
Member

su-chang commented Oct 16, 2020

@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
Copy link
Author

suntong commented Oct 16, 2020

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!

@suntong suntong closed this as completed Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants