@@ -28,7 +28,6 @@ import { filter, takeUntil, first } from 'rxjs/operators';
28
28
import Daemon from './daemon' ;
29
29
30
30
// Required agent version
31
- const MIN_VERSION = '1.1.80' ;
32
31
const browser = detect ( ) ;
33
32
const POLLING_INTERVAL = 3500 ;
34
33
const UPLOAD_DONE_TIMER = 5000 ;
@@ -139,19 +138,25 @@ export default class SocketDaemon extends Daemon {
139
138
} ) ;
140
139
141
140
if ( found ) {
142
- if ( this . agentInfo . version && ( semVerCompare ( this . agentInfo . version , MIN_VERSION ) >= 0 || this . agentInfo . version . indexOf ( 'dev' ) !== - 1 ) ) {
143
- return this . agentInfo ;
144
- }
145
-
146
- updateAttempts += 1 ;
147
- if ( updateAttempts === 0 ) {
148
- return this . update ( ) ;
149
- }
150
- if ( updateAttempts < 3 ) {
151
- return timer ( 10000 ) . subscribe ( ( ) => this . update ( ) ) ;
152
- }
153
- this . error . next ( 'plugin version incompatible' ) ;
154
- return Promise . reject ( new Error ( 'plugin version incompatible' ) ) ;
141
+ return fetch ( 'https://s3.amazonaws.com/arduino-create-static/agent-metadata/agent-version.json' )
142
+ . then ( response => response . json ( ) . then ( data => {
143
+ if ( this . agentInfo . version && ( semVerCompare ( this . agentInfo . version , data . Version ) >= 0 || this . agentInfo . version . indexOf ( 'dev' ) !== - 1 ) ) {
144
+ return this . agentInfo ;
145
+ }
146
+
147
+ updateAttempts += 1 ;
148
+ if ( updateAttempts === 0 ) {
149
+ return this . update ( ) ;
150
+ }
151
+ if ( updateAttempts < 3 ) {
152
+ return timer ( 10000 ) . subscribe ( ( ) => this . update ( ) ) ;
153
+ }
154
+ this . error . next ( 'plugin version incompatible' ) ;
155
+ return Promise . reject ( new Error ( 'plugin version incompatible' ) ) ;
156
+ } ) )
157
+ . catch ( ( ) =>
158
+ // If version API broken, go ahead with current version
159
+ this . agentInfo ) ;
155
160
}
156
161
157
162
// Set channelOpen false for the first time
0 commit comments