Closed huan closed 2 years ago
Fixed on esm
branch, publised with 1.11.x.
@padlocal It's great to know that this issue has been fixed.
However, could you please link the related commit to this issue so that we can confirm it?
And I checked the NPM but can not find the published v1.11 version as you said, could you please help us to double confirm it?
Thank you very much!
Link to:
ping @padlocal
The Problem
await puppetPadlocal.start()
will never resolve.Walk through
When we are starting the
PuppetPadlocal
by calling it'sstart()
method, it will check thethis.state.on()
: if it'strue
, then it will wait it becomesready()
then return. This design is to protect the puppet from being calledstart()
on an already starting one.However, when we are calling the
start()
the second time, the PuppetPadlocal will run into a deadlock, until the user login. If there's no user login (scan the QR code), then thestart()
will never resolve.The below code will wait the
this.state.ready()
:https://github.com/padlocal/wechaty-puppet-padlocal/blob/a4b04b723fc4f75d08596a2952e08f4b5037983c/src/puppet-padlocal.ts#L145-L148
However, the below code shows that the
state
will be onlyready('on')
after the user logged in:https://github.com/padlocal/wechaty-puppet-padlocal/blob/a4b04b723fc4f75d08596a2952e08f4b5037983c/src/puppet-padlocal.ts#L247
Need to be fixed.
Solution
The best solution is to follow the latest Wechaty v1.x design: use the
ServiceCtl
and put all start code inside theonStart()
method.The
ServiceCtl
will take care of all thestate
related management staffs.