Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
b01c0301
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b01c0301
编写于
11月 15, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean, add timeout for quit
上级
78753b7e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
29 deletion
+32
-29
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+32
-27
test/puppet-web/watchdog.spec.ts
test/puppet-web/watchdog.spec.ts
+0
-2
未找到文件。
src/puppet-web/puppet-web.ts
浏览文件 @
b01c0301
...
...
@@ -117,16 +117,14 @@ export class PuppetWeb extends Puppet {
if
(
this
.
state
.
current
()
===
'
dead
'
)
{
if
(
this
.
state
.
inprocess
())
{
log
.
warn
(
'
PuppetWeb
'
,
'
quit() is called but state.current() is `dead` and inprocess() ?
'
)
throw
new
Error
(
'
do not call quit again when quiting
'
)
const
e
=
new
Error
(
'
quit() is called on a `dead` `inprocess()` browser
'
)
log
.
warn
(
'
PuppetWeb
'
,
e
.
message
)
throw
e
}
log
.
warn
(
'
PuppetWeb
'
,
'
quit() is called
but state.current() is `dead`, return and will not run quit() again(do nothing)
.
'
)
log
.
warn
(
'
PuppetWeb
'
,
'
quit() is called
on a `dead` browser. return directly
.
'
)
return
}
// XXX should we set `target` to `dead` in `quit()` ???
// this.state.target('dead')
/**
* must feed POISON to Watchdog
* before state set to `dead` & `inprocess`
...
...
@@ -143,29 +141,36 @@ export class PuppetWeb extends Puppet {
try
{
await
this
.
bridge
.
quit
()
.
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit() bridge.quit() exception: %s
'
,
e
.
message
)
})
// log.verbose('PuppetWeb', 'quit() bridge.quit() this.bridge = null')
// this.bridge = null
await
this
.
server
.
quit
()
.
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit() server.quit() exception: %s
'
,
e
.
message
)
})
// this.server = null
// log.verbose('PuppetWeb', 'quit() server.quit() this.server = null')
await
this
.
browser
.
quit
()
.
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit() browser.quit() exception: %s
'
,
e
.
message
)
})
// log.verbose('PuppetWeb', 'quit() server.quit() this.browser = null')
// this.browser = null
await
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
timer
=
setTimeout
(()
=>
{
const
e
=
new
Error
(
'
quit() Promise() timeout
'
)
log
.
warn
(
'
PuppetWeb
'
,
e
.
message
)
reject
(
e
)
})
await
this
.
bridge
.
quit
()
.
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit() bridge.quit() exception: %s
'
,
e
.
message
)
})
log
.
verbose
(
'
PuppetWeb
'
,
'
quit() bridge.quit() done
'
)
await
this
.
server
.
quit
()
.
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit() server.quit() exception: %s
'
,
e
.
message
)
})
log
.
verbose
(
'
PuppetWeb
'
,
'
quit() server.quit() done
'
)
await
this
.
browser
.
quit
()
.
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit() browser.quit() exception: %s
'
,
e
.
message
)
})
log
.
verbose
(
'
PuppetWeb
'
,
'
quit() browser.quit() done
'
)
clearTimeout
(
timer
)
resolve
()
})
this
.
state
.
current
(
'
dead
'
)
log
.
silly
(
'
PuppetWeb
'
,
'
quit() done
'
)
return
...
...
test/puppet-web/watchdog.spec.ts
浏览文件 @
b01c0301
...
...
@@ -60,8 +60,6 @@ test('timer', async t => {
pw
.
addListener
(
'
error
'
,
failOnUnexpectedErrorEvent
)
}
// pw.once('error', e => t.fail('waitDing() triggered watchDogReset()'))
const
EXPECTED_DING_DATA
=
'
dingdong
'
pw
.
emit
(
'
watchdog
'
,
{
data
:
'
feed to extend the dog life
'
,
timeout
:
120000
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录