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

try to fix memory leak (#981)

上级 f6ec50f4
......@@ -122,12 +122,18 @@ export class PuppetPuppeteer extends Puppet {
*/
this.state.on(true)
/**
* Feed the dog and start watch
*/
const food: WatchdogFood = {
data: 'inited',
timeout: 2 * 60 * 1000, // 2 mins for first login
}
this.emit('watchdog', food)
/**
* Save cookie for every 5 minutes
*/
const throttleQueue = new ThrottleQueue(5 * 60 * 1000)
this.on('heartbeat', data => throttleQueue.next(data))
throttleQueue.subscribe(async data => {
......@@ -158,6 +164,9 @@ export class PuppetPuppeteer extends Puppet {
// clean the dog because this could be re-inited
this.watchdog.removeAllListeners()
// fix issue #981
puppet.removeAllListeners('watchdog')
puppet.on('watchdog', food => this.watchdog.feed(food))
this.watchdog.on('feed', food => {
log.silly('PuppetPuppeteer', 'initWatchdogForPuppet() dog.on(feed, food={type=%s, data=%s})', food.type, food.data)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册