juzibot / wechaty-puppet-macpro

One puppet based on Mac WeChat for Wechaty.
Apache License 2.0
38 stars 10 forks source link

Error: roomRawPayload() no cacheManager #62

Closed mrtoorich closed 4 years ago

mrtoorich commented 4 years ago

Important:Please file the issue follow the template, or we won't help you to solve the problem.

0. Report Issue Guide

  1. Please run the following command and check whether the problem has been fixed:
npm install wechaty-puppet-macpro
  1. Please search in the issue first, and make sure your problem had not been reported before

1. Versions

2. Describe the bug

Give a clear and concise description of what the bug is.

When I started the bot script, sometimes the errror 'Error: roomRawPayload() no cacheManager' shows, sometimes not. About 30% possibility.

3. To Reproduce

This part is very important: if you can not provide any reproduce steps, then the problem will be very hard to be recognized.

Steps to reproduce the behavior:

  1. run 'node bot.js'

.env:

WECHATY_TOKEN=puppet_macpro_xxx
WECHATY_NAME=test

bot.js:

const { parsed: config } = require('dotenv').config();

const { Wechaty, MiniProgram } = require('wechaty');
const { PuppetMacpro: Puppet } = require('wechaty-puppet-macpro');

const puppet = new Puppet({ token: config.WECHATY_TOKEN });
const bot = new Wechaty({ puppet, name: config.WECHATY_NAME });

bot
  .on('scan', (qrcode, status) => {
    console.log(`微信扫码登录: ${status}`);
    console.log(`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(qrcode)}`);
  })
  .on('login', async (user) => {
    // console.log(`登录用户: ${user}`);
  })
  .start();
  1. Sometimes the error shows.

4. Expected behavior

Give a clear and concise description of what you expected to happen.

Should not show errors.

5. Actual behavior

If applicable, add screenshots to help explain your problem. But do not paste log screenshots here.

6. Full Output Logs

Set env WECHATY_LOG=silly in order to set log level to silly, then we can get the full log (If you dosen't set log env, log level is info as default, we cannot get the full log)

We need full log instead of log screenshot or log fragments!

Show Logs ```shell 20:46:13 SILL Config WECHATY_LOG set level to silly 20:46:13 INFO Config registering process.on("unhandledRejection") for development/debug 20:46:13 VERB Config constructor() 20:46:14 VERB Puppet constructor({"token":"puppet_macpro_04ba0ca66f731f48"}) #0 20:46:14 VERB StateSwitch constructor(name=PuppetMacpro) 20:46:14 VERB MemoryCard constructor(undefined) 20:46:14 VERB MemoryCard getStorage() for storage type: N/A 20:46:14 VERB MemoryCard load() from storage: N/A 20:46:14 VERB MemoryCard load() no storage 20:46:14 VERB Puppet constructor() watchdog timeout set to 60 seconds 20:46:14 VERB HotImport callerResolve(., /Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet@0.20.2@wechaty-puppet/dist/src/puppet.js) 20:46:14 SILL HotImport callerResolve() callsites() file=/Users/huachen/Dev/zao/wechaty-test/node_modules/_hot-import@0.2.14@hot-import/dist/src/hot-import.js, type=Object 20:46:14 SILL HotImport callerResolve() callsites() file=/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet@0.20.2@wechaty-puppet/dist/src/puppet.js, type=null 20:46:14 SILL HotImport callerResolve() callsites() file=/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet-macpro@0.4.0@wechaty-puppet-macpro/dist/src/puppet-macpro.js, type=null 20:46:14 SILL HotImport callerResolve() callerFile=/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet-macpro@0.4.0@wechaty-puppet-macpro/dist/src/puppet-macpro.js 20:46:14 VERB Puppet constructor() childClassPath=/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet-macpro@0.4.0@wechaty-puppet-macpro/dist/src 20:46:14 SILL Accessory #0 constructor() 20:46:14 VERB Wechaty contructor() 20:46:14 VERB StateSwitch constructor(name=Wechaty) 20:46:14 VERB StateSwitch constructor(name=WechatyReady) 20:46:14 VERB Wechaty on(scan, function) registered 20:46:14 VERB Wechaty addListenerFunction(scan) 20:46:14 VERB Wechaty on(login, function) registered 20:46:14 VERB Wechaty addListenerFunction(login) 20:46:14 VERB Wechaty on(message, function) registered 20:46:14 VERB Wechaty addListenerFunction(message) 20:46:14 VERB Wechaty on(friendship, function) registered 20:46:14 VERB Wechaty addListenerFunction(friendship) 20:46:14 INFO Wechaty ()>(test) start() v0.32.5 is starting... 20:46:14 VERB Wechaty puppet: Puppet#0() 20:46:14 VERB Wechaty name: test 20:46:14 VERB Wechaty id: ck7hlq4nb00002gvcdhftcyld 20:46:14 SILL StateSwitch on() is false 20:46:14 SILL StateSwitch off() is true 20:46:14 VERB StateSwitch off(true) <- (true) 20:46:14 SILL StateSwitch on() is false 20:46:14 VERB StateSwitch on(pending) <- (false) 20:46:14 VERB MemoryCard constructor("test") 20:46:14 VERB MemoryCard getStorage() for storage type: N/A 20:46:14 VERB getStorage name: test, options: {"type":"file"} 20:46:14 VERB StorageFile constructor(test, ...) 20:46:14 VERB StorageBackend constructor(test, { type: file }) 20:46:14 VERB MemoryCard load() from storage: StorageFile 20:46:14 VERB StorageFile load() from /Users/huachen/Dev/zao/wechaty-test/test.memory-card.json 20:46:14 VERB Puppet constructor() memory.load() done 20:46:14 VERB Wechaty initPuppet() Puppet#0() 20:46:14 VERB MemoryCard multiplex(puppet) 20:46:14 VERB MemoryCard static multiplex(MemoryCard, puppet) 20:46:14 VERB MemoryCard constructor({"name":"test","multiplex":{"name":"puppet","parent":{"options":{"name":"test"},"name":"test","payload":{"\rpuppet\nWECHATY_PUPPET_MACPRO":{"taskId":113648,"userName":"XLX1231231234","wxid":"wxid_c4o4rxsratmb22"}},"multiplexNameList":[],"storage":{"name":"test","options":{"type":"file"},"absFileName":"/Users/huachen/Dev/zao/wechaty-test/test.memory-card.json"}}}}) 20:46:14 VERB PuppetManager resolve({puppet: Puppet#0(), puppetOptions: undefined}) 20:46:14 VERB PuppetManager resolveInstance(Puppet#0()) 20:46:14 VERB Puppet setMemory() 20:46:14 VERB Wechaty initPuppetEventBridge(Puppet#0(test)) 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(friendship) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(login) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(logout) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(message) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(room-invite) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(room-join) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(room-leave) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(room-topic) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(scan) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(dong) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(error) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(ready) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(reset) registered 20:46:14 VERB Wechaty initPuppetEventBridge() puppet.on(watchdog) registered 20:46:14 VERB Wechaty initAccessory(Puppet#0(test)) 20:46:14 SILL Accessory static set wechaty = "Wechaty#ck7hlq4nb00002gvcdhftcyld(test)>(test)" 20:46:14 SILL Accessory static set wechaty = "Wechaty#ck7hlq4nb00002gvcdhftcyld(test)>(test)" 20:46:14 SILL Accessory static set wechaty = "Wechaty#ck7hlq4nb00002gvcdhftcyld(test)>(test)" 20:46:14 SILL Accessory static set wechaty = "Wechaty#ck7hlq4nb00002gvcdhftcyld(test)>(test)" 20:46:14 SILL Accessory static set wechaty = "Wechaty#ck7hlq4nb00002gvcdhftcyld(test)>(test)" 20:46:14 SILL Accessory static set wechaty = "Wechaty#ck7hlq4nb00002gvcdhftcyld(test)>(test)" 20:46:14 SILL Accessory static set wechaty = "Wechaty#ck7hlq4nb00002gvcdhftcyld(test)>(test)" 20:46:14 SILL Accessory static set wechaty = "Wechaty#ck7hlq4nb00002gvcdhftcyld(test)>(test)" 20:46:14 SILL Accessory static set puppet = "Puppet#0(test)" 20:46:14 SILL Accessory static set puppet = "Puppet#0(test)" 20:46:14 SILL Accessory static set puppet = "Puppet#0(test)" 20:46:14 SILL Accessory static set puppet = "Puppet#0(test)" 20:46:14 SILL Accessory static set puppet = "Puppet#0(test)" 20:46:14 SILL Accessory static set puppet = "Puppet#0(test)" 20:46:14 SILL Accessory static set puppet = "Puppet#0(test)" 20:46:14 SILL Accessory static set puppet = "Puppet#0(test)" 20:46:14 SILL Accessory set puppet = "Puppet#0(test)" 20:46:14 SILL PuppetMacpro start() 20:46:14 SILL StateSwitch on() is false 20:46:14 VERB StateSwitch on(pending) <- (false) 20:46:14 SILL GrpcGateway notify(getLoginUserInfo, undefined) 20:46:14 VERB GrpcGateway on(heartbeat, function) registered 20:46:14 VERB GrpcGateway on(reconnect, function) registered 20:46:14 VERB GrpcGateway on(scan, function) registered 20:46:14 VERB GrpcGateway on(login, function) registered 20:46:14 VERB GrpcGateway on(logout, function) registered 20:46:14 VERB GrpcGateway on(not-login, function) registered 20:46:14 VERB GrpcGateway on(message, function) registered 20:46:14 VERB GrpcGateway on(contact-list, function) registered 20:46:14 VERB GrpcGateway on(room-list, function) registered 20:46:14 VERB GrpcGateway on(contact-info, function) registered 20:46:14 VERB GrpcGateway on(contact-remark, function) registered 20:46:14 VERB GrpcGateway on(room-info, function) registered 20:46:14 VERB GrpcGateway on(room-join, function) registered 20:46:14 VERB GrpcGateway on(room-member, function) registered 20:46:14 VERB GrpcGateway on(room-qrcode, function) registered 20:46:14 VERB GrpcGateway on(new-friend, function) registered 20:46:14 VERB GrpcGateway on(add-friend, function) registered 20:46:14 VERB GrpcGateway on(del-friend, function) registered 20:46:14 VERB GrpcGateway on(add-friend-before-accept, function) registered 20:46:14 SILL StateSwitch on() is pending 20:46:14 VERB StateSwitch on(true) <- (pending) 20:46:14 VERB Wechaty on(heartbeat, function) registered 20:46:14 VERB Wechaty addListenerFunction(heartbeat) 20:46:14 SILL StateSwitch on() is pending 20:46:14 VERB StateSwitch on(true) <- (pending) 20:46:14 SILL GrpcGateway callback type:【login】 20:46:14 SILL Wechaty memoryCheck() free: 476 MB, require: 4 MB 20:46:14 INFO PuppetMacpro ============================== Login Success ============================== 20:46:14 VERB PuppetMacpro init cache manager 20:46:14 VERB CacheManager init() 20:46:14 VERB CacheManager initCache(XLX1231231234) 20:46:14 SILL GrpcGateway callback type:【message】 20:46:14 VERB PuppetMacpro onProcessMessage() 20:46:14 VERB PuppetMacpro onMacproMessageFriendshipEvent({id=1695792032}) 20:46:14 VERB Message static load(1695792032) 20:46:14 SILL Accessory #1 constructor() 20:46:14 VERB Message constructor(1695792032) for class Message 20:46:14 VERB Message ready() 20:46:14 VERB Puppet messagePayload(1695792032) 20:46:14 SILL Puppet messagePayloadCache(1695792032) cache MISS 20:46:14 VERB PuppetMacpro messageRawPayload(1695792032) 20:46:14 VERB PuppetMacpro messageRawPayloadParser({"my_account":"XLX1231231234","my_name":"lit toffee","my_account_alias":"wxid_c4o4rxsratmb22","to_account":"wxid_u8d9ubklkriu22","to_account_alias":"","to_name":"朵朵","g_number":"9881218427@chatroom","g_name":"晋江清醇汉文化社","content":"真他妈难打","content_type":1,"file_name":"","voice_len":0,"msgid":1695792032,"msg_source":"\n\t0\n\t187\n\n","send_time":1583585174,"messageId":"1695792032","timestamp":1583585174}) 20:46:14 SILL messageRawPayloadParser messageType 7 20:46:14 SILL Puppet messagePayload(1695792032) cache SET 20:46:14 SILL Accessory #2 constructor() 20:46:14 SILL Room constructor(9881218427@chatroom) 20:46:14 VERB Room ready() 20:46:14 VERB Puppet roomPayload(9881218427@chatroom) 20:46:14 SILL Puppet roomPayloadCache(9881218427@chatroom) cache MISS 20:46:14 VERB PuppetMacpro roomRawPayload(9881218427@chatroom) 20:46:14 ERR Config ########################### 20:46:14 ERR Config unhandledRejection: Error: roomRawPayload() no cacheManager [object Promise] 20:46:14 ERR Config ########################### 20:46:14 ERR Config process.on(unhandledRejection) promise.catch(roomRawPayload() no cacheManager) Config Error: roomRawPayload() no cacheManager at Object.exports.CacheManageError (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet-macpro@0.4.0@wechaty-puppet-macpro/dist/src/utils/errorMsg.js:4:12) at PuppetMacpro. (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet-macpro@0.4.0@wechaty-puppet-macpro/dist/src/puppet-macpro.js:1186:34) at Generator.next () at /Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet-macpro@0.4.0@wechaty-puppet-macpro/dist/src/puppet-macpro.js:8:71 at new Promise () at __awaiter (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet-macpro@0.4.0@wechaty-puppet-macpro/dist/src/puppet-macpro.js:4:12) at PuppetMacpro.roomRawPayload (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet-macpro@0.4.0@wechaty-puppet-macpro/dist/src/puppet-macpro.js:1183:16) at PuppetMacpro. (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet@0.20.2@wechaty-puppet/dist/src/puppet.js:808:43) at Generator.next () at /Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet@0.20.2@wechaty-puppet/dist/src/puppet.js:26:71 at new Promise () at __awaiter (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet@0.20.2@wechaty-puppet/dist/src/puppet.js:22:12) at PuppetMacpro.roomPayload (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty-puppet@0.20.2@wechaty-puppet/dist/src/puppet.js:793:16) at AnotherOriginalClass. (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty@0.32.5@wechaty/dist/src/user/room.js:296:46) at Generator.next () at /Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty@0.32.5@wechaty/dist/src/user/room.js:8:71 at new Promise () at __awaiter (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty@0.32.5@wechaty/dist/src/user/room.js:4:12) at AnotherOriginalClass.ready (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty@0.32.5@wechaty/dist/src/user/room.js:287:16) at AnotherOriginalClass. (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty@0.32.5@wechaty/dist/src/user/message.js:694:54) at Generator.next () at fulfilled (/Users/huachen/Dev/zao/wechaty-test/node_modules/_wechaty@0.32.5@wechaty/dist/src/user/message.js:5:58) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:13048) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2) 20:46:14 VERB CacheManager initCache() inited 3084 Contacts, cachedir="/Users/huachen/.wechaty/puppet-macpro-cache/flash-store-v0.14/XLX1231231234" 20:46:14 VERB Puppet login(wxid_c4o4rxsratmb22) 20:46:14 VERB Contact load(wxid_c4o4rxsratmb22) init pool 20:46:14 SILL Accessory #3 constructor() 20:46:14 SILL Contact constructor(wxid_c4o4rxsratmb22) 20:46:14 SILL Contact ready() @ Puppet#0(test) with id="wxid_c4o4rxsratmb22" 20:46:14 SILL Puppet contactPayload(wxid_c4o4rxsratmb22) cache MISS 20:46:14 VERB PuppetMacpro contactRawPayload(wxid_c4o4rxsratmb22) 20:46:14 VERB MemoryCard set(WECHATY_PUPPET_MACPRO, [object Object]) 20:46:14 VERB MemoryCard save() to StorageFile 20:46:14 VERB StorageFile save() to /Users/huachen/Dev/zao/wechaty-test/test.memory-card.json 20:46:14 VERB PuppetMacpro contactRawPayloadParser() 20:46:14 SILL Puppet contactPayload(wxid_c4o4rxsratmb22) cache SET ```

7. Additional context

Add any other context about the problem here.

[bug]

su-chang commented 4 years ago

Sorry, I can not reproduce this bug. More detail reproduce steps are wanted.