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

fix injectio init return value

上级 b863ed3a
......@@ -91,8 +91,7 @@ class Bridge {
return this.proxyWechaty('init')
})
.then(r => {
if (true!==r) { throw new Error('Wechaty.init() failed: ' + r) }
log.verbose('Bridge', 'Wechaty.init() successful: %s', r)
log.verbose('Bridge', 'Wechaty.init() return: %s', r)
return r
})
.catch (e => {
......@@ -135,4 +134,4 @@ Object.keys(window._chatContent).filter(function (k) { return window._chatConten
.web_wechat_tab_add
.web_wechat_tab_launch-chat
*
*/
\ No newline at end of file
*/
......@@ -92,13 +92,13 @@ return (function(port) {
function init() {
if (Wechaty.vars.inited === true) {
log('Wechaty.init() called twice: already inited')
return
return 'init: already inited'
}
if (!isReady()) {
clog('angular not ready. wait 500ms...')
setTimeout(init, 1000)
return // AngularJS not ready, wait 500ms then try again.
return 'init: entered waiting angular loop'// AngularJS not ready, wait 500ms then try again.
}
clog('init on port:' + port)
......@@ -111,7 +111,8 @@ return (function(port) {
heartBeat()
clog('inited!. ;-D')
return Wechaty.vars.inited = true
Wechaty.vars.inited = true
return 'init: success'
}
function heartBeat() {
......
......@@ -145,6 +145,14 @@ class PuppetWeb extends Puppet {
})
return this.bridge.init()
.catch(e => {
if (this.browser.dead()) {
log.warn('PuppetWeb', 'initBridge() found browser dead, wait to restore')
} else {
log.error('PuppetWeb', 'initBridge() init fail: %s', e.message)
throw e
}
})
}
initServer() {
log.verbose('PuppetWeb', 'initServer()')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册