-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[RFC] Launch broken when using wechaty-puppet-padchat #1575
Comments
I will try to fix this in |
@windmemory thanks for the analysis! I have a question:
And, BTW: If you populate room member data into contact, then please also consider a situation: one contact is the bot's friend and it also in one room. If you populate the room member data to contact payload, then the contact payload will be the room member data instead of a normal contact payload,some properties might be empty forever because it will not be get from the server anymore. |
Patch fix: wechaty/wechaty-puppet-padchat@03fa49f |
@zixia I think you make a good point here, I should also consider the situation that you brought up. I think when we are syncing contact, contact will always override the data in cache for lower level(puppet-padchat), thus it is promised that the data in the cache will be correct eventually. But for upper level(wecahty), I think it would be hard to determine that whether a contact is a friend or stranger in a room. Do you have any better idea? |
Thanks for the fix! About the contact payload, a friend payload will be different with a room member payload, especially when the room member is a stranger(not a friend) to the bot, which is the most common case. Let's start thinking and try to find a better way to solve this problem. |
Yeah, I do understand the difference between a friend and a stranger. The thing that I was struggled with is that, from If we re-consider the design we have currently, maybe we change the flow that we are loading these contact. We could mimic the behavior in wechat app. Unless we want to check the detail data for a user, we never get the information from wechat. For basic usage, like search or get the list, properties Let me know your thought. Maybe we could also discuss this face to face. |
Did you find the reason that caused so many As I remember, Wechaty will only call |
Notice the code I pasted above await Promise.all(
memberIdList
.map(id => this.wechaty.Contact.load(id))
.map(contact => {
contact.ready()
.catch(e => {
log.verbose('Room', 'ready() member.ready() rejection: %s', e)
})
}),
) This is loading the room member as a contact, if the data is not loaded, |
Can we get rid of this part of the code? I can not remember more details, but it seems that load all payload at here is not a good idea for now. |
From my understanding, I think it should be okay to remove it. do you need me to send out a PR for this? |
Thanks for share your thought. Please hold it to think it more for some days, we do not make a decision right now. |
Okay, let's discuss this later. |
I think this could be closed since the issue is not exist anymore. |
Glad to hear that, thanks! |
Recently we found that launching a brand new account with
wechaty
usually caused broken. It got broken in the middle of sync contact and room process.Here are some findings when I dig into the logs:
I realized that after these part of logs,
wechaty-puppet-padchat
started to callWXGenContact
rapidly, from my estimate, it would be more than 50 times/s, which is an abnormal behavior. I think this is the root cause of the broken.This is triggered by new message, so I looked into the code that we deal with the new message:
When we receive a new message, we call
Message.ready()
method. Here is theMessage.ready()
method:As we can see, this
Message.ready()
method will also call theready()
method onfromId
,roomId
andtoId
. Here is theRoom.ready()
function:From the code above, I noticed that this logic will call
Contact.ready()
on each room member. Ifwechaty
is just started, the data of room member won't be in contact, so it will fire up anWXGetContact
request to Wechat server.The text was updated successfully, but these errors were encountered: