File tree 2 files changed +17
-2
lines changed 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -69,8 +69,11 @@ export default class SocketDaemon extends Daemon {
69
69
. subscribe ( agentFound => {
70
70
if ( agentFound ) {
71
71
this . _wsConnect ( ) ;
72
- this . v2 = new V2 ( this . pluginURL ) ;
73
- this . agentV2Found . next ( this . v2 ) ;
72
+ const v2 = new V2 ( this . pluginURL ) ;
73
+ v2 . init ( ) . then ( ( ) => {
74
+ this . v2 = v2 ;
75
+ this . agentV2Found . next ( this . v2 ) ;
76
+ } ) ;
74
77
}
75
78
else {
76
79
this . findAgent ( ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,18 @@ export default class SocketDaemonV2 {
3
3
this . daemonURL = `${ daemonURL } /v2` ;
4
4
}
5
5
6
+ // init tries an HEAD
7
+ init ( ) {
8
+ return fetch ( `${ this . daemonURL } /pkgs/tools/installed` , {
9
+ method : 'HEAD' ,
10
+ } ) . then ( res => {
11
+ if ( res . status !== 200 ) {
12
+ throw Error ( 'v2 not available' ) ;
13
+ }
14
+ return res ;
15
+ } ) ;
16
+ }
17
+
6
18
// installedTools uses the new v2 apis to ask the daemon a list of the tools already present in the system
7
19
installedTools ( ) {
8
20
return fetch ( `${ this . daemonURL } /pkgs/tools/installed` , {
You can’t perform that action at this time.
0 commit comments