forked from wechaty/puppet-service
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
问题描述:
修改联系人相关信息,收到dirty事件后,没有对比出信息变更的差异,导致无法及时更新联系人的数据。
收到dirty事件后,根据日志分析 PuppetContactMixin 中的缓存均被清理掉(cache MISS),调用 puppet-service 层获取数据时,正常日志为 cache SET 而异常日志为 cache HIT
目前怀疑导致该问题的原因是 puppet-service 删除flash-store中的缓存数据耗时较大,导致wechaty再次请求新的底层数据时,仍获取到的为旧数据。
解决方案
获取新数据时增加小量延迟(100毫秒)
经过测试,可以完美解决该问题,甚至延迟可以减小至50毫秒
将删除缓存的操作前置
由于 onDirty 函数在[email protected]中已经改造为异步函数,在触发dirty事件前,await onDirty()即可。
日志
正常日志
22:19:19 SILL PuppetContactMixin contactPayload(7881301676927825) cache MISS
22:19:19 VERB PuppetService contactRawPayload(7881301676927825)
22:19:19 SILL PuppetService contactRawPayload(7881301676927825) cache SET
22:19:19 SILL PuppetContactMixin contactPayload(7881301676927825) cache SET
get contact payload last 7881301676927825
newPayload {"address":"","alias":"苏嘎嘎嘎","avatar":"http://wx.qlogo.cn/mmhead/Ksm9rvSibEfZKrGiaia9VE3tB7DAKdDIicu4mz0OBibUPYfg/0","city":"","corporation":"VVV哥哥","coworker":false,"description":"","friend":true,"gender":1,"handle":"wmrRhyBgAA8Jqa5uhpp3iR6rjFQ3nQxg","id":"7881301676927825","name":"苏畅","phone":["2229999","58558"],"province":"","signature":"","star":false,"title":"wmrRhyBgAA8Jqa5uhpp3iR6rjFQ3nQxg","type":1,"weixin":"wmrRhyBgAA8Jqa5uhpp3iR6rjFQ3nQxg","additionalInfo":"{\"corpId\":\"1970325134026788\",\"sCorpId\":\"wwc7c9f32a3160d4dc\",\"addCustomerTime\":1697813284,\"status\":2}","tags":["14073749169601652","14073749760770190","14073750853776359","14073752645717237","14073752747749178"]}
22:19:19 SILL Tag find({"id":"14073750853776359"})
22:19:19 SILL Tag ready() @ Puppet<PuppetService>(NONAME) with Tag key="14073750853776359"
22:19:19 SILL Tag ready() isReady() true
============================
CONTACT-TAG-ADD-EVENT length: 1 Contact<苏嘎嘎嘎> [{"id":"14073750853776359","payload":{"id":"14073750853776359","name":"6dad;al的;拉代码;脸上","groupId":"14073752626783686","type":2}}]
============================
异常日志
22:19:32 SILL PuppetContactMixin contactPayload(7881301676927825) cache MISS
22:19:32 VERB PuppetService contactRawPayload(7881301676927825)
22:19:32 SILL PuppetService contactRawPayload(7881301676927825) cache HIT
22:19:32 SILL PuppetContactMixin contactPayload(7881301676927825) cache SET
get contact payload last 7881301676927825
newPayload {"address":"","alias":"苏嘎嘎嘎","avatar":"http://wx.qlogo.cn/mmhead/Ksm9rvSibEfZKrGiaia9VE3tB7DAKdDIicu4mz0OBibUPYfg/0","city":"","corporation":"VVV哥哥","coworker":false,"description":"","friend":true,"gender":1,"handle":"wmrRhyBgAA8Jqa5uhpp3iR6rjFQ3nQxg","id":"7881301676927825","name":"苏畅","phone":["2229999","58558"],"province":"","signature":"","star":false,"title":"wmrRhyBgAA8Jqa5uhpp3iR6rjFQ3nQxg","type":1,"weixin":"wmrRhyBgAA8Jqa5uhpp3iR6rjFQ3nQxg","additionalInfo":"{\"corpId\":\"1970325134026788\",\"sCorpId\":\"wwc7c9f32a3160d4dc\",\"addCustomerTime\":1697813284,\"status\":2}","tags":["14073749169601652","14073749760770190","14073750853776359","14073752645717237","14073752747749178"]}
22:19:32 INFO WechatyPuppetMixin got dirty for contact 7881301676927825 but cannot find any difference.
Metadata
Metadata
Assignees
Labels
No labels