@@ -76,7 +76,10 @@ export default class SocketDaemon extends Daemon {
7676
7777 this . agentFound
7878 . subscribe ( agentFound => {
79- if ( ! agentFound ) {
79+ if ( agentFound ) {
80+ this . _wsConnect ( ) ;
81+ }
82+ else {
8083 this . findAgent ( ) ;
8184 }
8285 } ) ;
@@ -144,20 +147,21 @@ export default class SocketDaemon extends Daemon {
144147
145148 if ( found ) {
146149 if ( this . agentInfo . version && ( semVerCompare ( this . agentInfo . version , MIN_VERSION ) >= 0 || this . agentInfo . version . indexOf ( 'dev' ) !== - 1 ) ) {
147- this . _wsConnect ( ) ;
148150 return this . agentInfo ;
149151 }
150152
151- this . channelOpen . next ( false ) ;
152-
153153 updateAttempts += 1 ;
154154 if ( updateAttempts === 0 ) {
155155 return this . update ( ) ;
156156 }
157- if ( updateAttempts < 5 ) {
157+ if ( updateAttempts < 4 ) {
158158 return timer ( 10000 ) . subscribe ( ( ) => this . update ( ) ) ;
159159 }
160- return this . error . next ( 'plugin version incompatible' ) ;
160+ const currentError = this . error . getValue ( ) ;
161+ if ( currentError !== 'plugin version incompatible' ) {
162+ this . error . next ( 'plugin version incompatible' ) ;
163+ }
164+ return Promise . reject ( new Error ( 'plugin version incompatible' ) ) ;
161165 }
162166
163167 // Set channelOpen false for the first time
@@ -250,7 +254,10 @@ export default class SocketDaemon extends Daemon {
250254 } ) . then ( ( ) => Promise . reject ( ) ) // We reject the promise because the daemon will be restarted, we need to continue looking for the port
251255 . catch ( err => {
252256 if ( err && err . data && err . data . error && ( err . data . error . indexOf ( 'proxy' ) !== - 1 || err . data . error . indexOf ( 'dial tcp' ) !== - 1 ) ) {
253- this . error . next ( 'proxy error' ) ;
257+ const currentError = this . error . getValue ( ) ;
258+ if ( currentError !== 'proxy error' ) {
259+ this . error . next ( 'proxy error' ) ;
260+ }
254261 }
255262 } ) ;
256263 }
0 commit comments