提交 e97b511d 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

do not remove all listeners before stop

上级 c3c36eb4
......@@ -538,12 +538,15 @@ export class Bridge extends EventEmitter {
/**
* Proxy Call to Wechaty in Bridge
*/
public async proxyWechaty(wechatyFunc: string, ...args: any[]): Promise<any> {
public async proxyWechaty(
wechatyFunc : string,
...args : any[],
): Promise<any> {
log.silly('PuppetWebBridge', 'proxyWechaty(%s%s)',
wechatyFunc,
args.length
? ' , ' + args.join(', ')
: '',
wechatyFunc,
args.length
? ' , ' + args.join(', ')
: '',
)
try {
......@@ -555,7 +558,7 @@ export class Bridge extends EventEmitter {
throw e
}
} catch (e) {
log.warn('PuppetWebBridge', 'proxyWechaty() noWechaty exception: %s', e.stack)
log.warn('PuppetWebBridge', 'proxyWechaty() noWechaty exception: %s', e)
throw e
}
......
......@@ -249,7 +249,9 @@ export class PuppetWeb extends Puppet {
throw e
} finally {
this.state.current('dead')
this.removeAllListeners()
// register the removeListeners micro task at then end of the task queue
// setImmediate(() => this.removeAllListeners())
}
}
......
......@@ -465,9 +465,9 @@ export class Wechaty extends EventEmitter implements Sayable {
this.state.current('off', true)
this.emit('stop')
// should use setImmediate here,
// because we need to run the micro task of the `emitt` event
setImmediate(() => this.removeAllListeners())
// MUST use setImmediate at here(the end of this function),
// because we need to run the micro task registered by the `emit` method
// setImmediate(() => this.removeAllListeners())
}
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册