This repository was archived by the owner on Nov 21, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -334,7 +334,7 @@ export default {
334334 .then (() => {
335335 return this .getVrouterInfo ()
336336 })
337- await Promise .race ([p1, p2])
337+ await Promise .all ([p1, p2])
338338 if (! silent) this .activeLoader = false
339339 },
340340 openLogFile : function () {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class Openwrt {
2020 * @param {int } timeout 连接前的等待时间(毫秒)
2121 * @return {promise } 当连接成功后resovle
2222 */
23- connect ( heartbeat = 0 , timeout = 8000 ) {
23+ connect ( heartbeat = 0 , timeout = 5000 ) {
2424 this . conn = new Client ( )
2525 return new Promise ( ( resolve , reject ) => {
2626 this . conn . on ( 'ready' , ( ) => {
@@ -66,12 +66,16 @@ class Openwrt {
6666 '/etc/init.d/firewall restart'
6767 ]
6868 return new Promise ( ( resolve , reject ) => {
69+ const timeoutID = setTimeout ( ( ) => {
70+ reject ( Error ( 'execute timeout. The connection between virtual machine and UI may been lost' ) )
71+ } , 8000 )
6972 this . conn . exec ( cmd , async ( err , stream ) => {
7073 if ( err ) {
7174 logger . debug ( `this.conn.exec() err: ${ err } ` )
7275 if ( ! retry ) {
7376 logger . debug ( `retry exec cmd via ssh` )
74- const output = await self . execute ( cmd , true )
77+ clearTimeout ( timeoutID )
78+ const output = await self . execute ( cmd , true ) . catch ( err => reject ( err ) )
7579 return resolve ( output . toString ( ) . trim ( ) )
7680 } else {
7781 logger . warn ( `retry execute cmd: ${ cmd } error. ${ err } ` )
You can’t perform that action at this time.
0 commit comments