wechaty / puppet-whatsapp

Wechaty Puppet for Whatsapp
https://npmjs.com/package/wechaty-puppet-whatsapp
Apache License 2.0
24 stars 17 forks source link

memory-card fail to load #336

Closed hcfw007 closed 2 years ago

hcfw007 commented 2 years ago
> wechaty-puppet-whatsapp@1.15.4 start
> cross-env NODE_OPTIONS='--no-warnings --loader=ts-node/esm' node examples/ding-dong-bot.ts

16:00:59 SILL Puppet Config: WECHATY_LOG set level to silly
16:00:59 VERB MemoryCard constructor({"name":"test-MC","storageOptions":{"type":"s3","accessKeyId":"someKey","secretAccessKey":"someOtherKey","region":"cn","bucket":"some-bucket"}})
16:00:59 VERB PuppetSkeleton constructor({"memory":{"name":"test-MC","multiplexNameList":[],"options":{"name":"test-MC","storageOptions":{"type":"s3","accessKeyId":"someKey","secretAccessKey":"someOtherKey","region":"cn","bucket":"some-bucket"}}}})
16:00:59 VERB PuppetMemoryMixin constructor()
16:00:59 VERB MemoryCard constructor(undefined)
16:00:59 VERB PuppetLoginMixin constructor()
16:00:59 VERB PuppetCacheMixin constructor()
16:00:59 VERB PuppetCacheAgent constructor()
16:00:59 VERB PuppetContactMixin constructor()
16:00:59 VERB PuppetRoomMemberMixin constructor()
16:00:59 VERB PuppetRoomMixin constructor()
16:00:59 VERB PuppetFriendshipMixin constructor()
16:00:59 VERB PuppetTagMixin constructor()
16:00:59 VERB PuppetRoomInvitationMixin constructor()
16:00:59 VERB PuppetMessageMixin constructor()
16:00:59 VERB PuppetMiscMixin constructor()
16:00:59 VERB ServiceCtl<PuppetServiceMixin> constructor()
16:00:59 VERB StateSwitch constructor(PuppetServiceMixin, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}")
16:00:59 VERB StateSwitch constructor(PuppetServiceMixinReset, "{"log":{"enableTimestamp":true,"logLevel":5,"prefixFilter":{}}}")
16:00:59 VERB PuppetServiceMixin constructor() #0
16:00:59 VERB PuppetWatchdogAgent constructor(7827abb1-9b98-42a0-9501-ab381104a5e1)
16:00:59 VERB PuppetWatchdogAgent constructor() timeout 60 seconds
16:00:59 VERB Watchdog <Puppet>: constructor(name=Puppet, defaultTimeout=60000)
16:00:59 VERB ReadyMixin constructor()
16:00:59 VERB PuppetPostMixin constructor()
16:00:59 VERB TapMixin constructor()
16:00:59 VERB Puppet constructor({"memory":{"name":"test-MC","multiplexNameList":[],"options":{"name":"test-MC","storageOptions":{"type":"s3","accessKeyId":"someKey","secretAccessKey":"someOtherKey","region":"cn","bucket":"some-bucket"}}}})
16:00:59 VERB PuppetWhatsapp constructor()
16:00:59 VERB ReadyMixin start()
16:00:59 VERB PuppetServiceMixin start()
16:00:59 VERB ServiceCtl<PuppetServiceMixin> start()
16:00:59 SILL StateSwitch <PuppetServiceMixin> active() is false
16:00:59 SILL StateSwitch <PuppetServiceMixin> inactive() is true
16:00:59 SILL StateSwitch <PuppetServiceMixin> active() is false
16:00:59 VERB StateSwitch <PuppetServiceMixin> active(pending) <- (false)
16:00:59 VERB ServiceCtl<PuppetServiceMixin> start() super.start() ...
16:00:59 VERB PuppetCacheMixin start()
16:00:59 VERB PuppetLoginMixin start()
16:00:59 VERB PuppetMemoryMixin start()
16:00:59 VERB MemoryCard load() from storage: N/A
16:00:59 VERB MemoryCard getStorage() for storage type: N/A

Puppet Version: 0.0.0

Please wait... I'm trying to login in...

16:00:59 VERB MemoryCard load() no storage
16:00:59 VERB PuppetSkeleton start()
16:00:59 VERB PuppetCacheAgent start()
16:00:59 VERB PuppetCacheMixin start() "dirty" event listener added
16:00:59 VERB ServiceCtl<PuppetServiceMixin> start() super.start() ... done
16:00:59 VERB ServiceCtl<PuppetServiceMixin> start() this.onStart() ...
16:00:59 VERB PuppetWhatsapp onStart()
16:00:59 VERB MemoryCard load() from storage: N/A
16:00:59 WARN PuppetWhatsapp memory card loaded already
16:00:59 VERB MemoryCard <> get(PUPPET_WHATSAPP)
16:00:59 ERR PuppetWhatsapp Can not start whatsapp, error: no payload, please call load() first.
Bot error: undefined
16:00:59 VERB ReadyMixin stop()

This is due to in https://github.com/wechaty/puppet-whatsapp/blob/3f7d8b5ebc9135a7234154765732737773011387/src/puppet-whatsapp.ts#L124 The memory called is still the one in option, not the instance processed by wechaty-puppet, and that caused this error.

Ref issue: https://github.com/wechaty/wechaty/issues/2373

hcfw007 commented 2 years ago

Fixed