@@ -31,22 +31,34 @@ export class StdioClientTransport implements Transport {
31
31
private _process ?: ChildProcess ;
32
32
private _abortController : AbortController = new AbortController ( ) ;
33
33
private _readBuffer : ReadBuffer = new ReadBuffer ( ) ;
34
+ private _serverParams : StdioServerParameters ;
34
35
35
36
onclose ?: ( ) => void ;
36
37
onerror ?: ( error : Error ) => void ;
37
38
onmessage ?: ( message : JSONRPCMessage ) => void ;
38
39
40
+ constructor ( server : StdioServerParameters ) {
41
+ this . _serverParams = server ;
42
+ }
43
+
39
44
/**
40
- * Spawns the server process and prepare to communicate with it.
45
+ * Starts the server process and prepares to communicate with it.
41
46
*/
42
- spawn ( server : StdioServerParameters ) : Promise < void > {
47
+ async start ( ) : Promise < void > {
43
48
return new Promise ( ( resolve , reject ) => {
44
- this . _process = spawn ( server . command , server . args ?? [ ] , {
45
- // The parent process may have sensitive secrets in its env, so don't inherit it automatically.
46
- env : server . env === undefined ? { } : { ...server . env } ,
47
- stdio : [ "pipe" , "pipe" , "inherit" ] ,
48
- signal : this . _abortController . signal ,
49
- } ) ;
49
+ this . _process = spawn (
50
+ this . _serverParams . command ,
51
+ this . _serverParams . args ?? [ ] ,
52
+ {
53
+ // The parent process may have sensitive secrets in its env, so don't inherit it automatically.
54
+ env :
55
+ this . _serverParams . env === undefined
56
+ ? { }
57
+ : { ...this . _serverParams . env } ,
58
+ stdio : [ "pipe" , "pipe" , "inherit" ] ,
59
+ signal : this . _abortController . signal ,
60
+ } ,
61
+ ) ;
50
62
51
63
this . _process . on ( "error" , ( error ) => {
52
64
if ( error . name === "AbortError" ) {
0 commit comments