File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 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 {
6969 . subscribe ( agentFound => {
7070 if ( agentFound ) {
7171 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+ } ) ;
7477 }
7578 else {
7679 this . findAgent ( ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,18 @@ export default class SocketDaemonV2 {
33 this . daemonURL = `${ daemonURL } /v2` ;
44 }
55
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+
618 // installedTools uses the new v2 apis to ask the daemon a list of the tools already present in the system
719 installedTools ( ) {
820 return fetch ( `${ this . daemonURL } /pkgs/tools/installed` , {
You can’t perform that action at this time.
0 commit comments