@@ -76,7 +76,10 @@ export default class SocketDaemon extends Daemon {
76
76
77
77
this . agentFound
78
78
. subscribe ( agentFound => {
79
- if ( ! agentFound ) {
79
+ if ( agentFound ) {
80
+ this . _wsConnect ( ) ;
81
+ }
82
+ else {
80
83
this . findAgent ( ) ;
81
84
}
82
85
} ) ;
@@ -144,20 +147,21 @@ export default class SocketDaemon extends Daemon {
144
147
145
148
if ( found ) {
146
149
if ( this . agentInfo . version && ( semVerCompare ( this . agentInfo . version , MIN_VERSION ) >= 0 || this . agentInfo . version . indexOf ( 'dev' ) !== - 1 ) ) {
147
- this . _wsConnect ( ) ;
148
150
return this . agentInfo ;
149
151
}
150
152
151
- this . channelOpen . next ( false ) ;
152
-
153
153
updateAttempts += 1 ;
154
154
if ( updateAttempts === 0 ) {
155
155
return this . update ( ) ;
156
156
}
157
- if ( updateAttempts < 5 ) {
157
+ if ( updateAttempts < 4 ) {
158
158
return timer ( 10000 ) . subscribe ( ( ) => this . update ( ) ) ;
159
159
}
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' ) ) ;
161
165
}
162
166
163
167
// Set channelOpen false for the first time
@@ -250,7 +254,10 @@ export default class SocketDaemon extends Daemon {
250
254
} ) . then ( ( ) => Promise . reject ( ) ) // We reject the promise because the daemon will be restarted, we need to continue looking for the port
251
255
. catch ( err => {
252
256
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
+ }
254
261
}
255
262
} ) ;
256
263
}
0 commit comments