@@ -44,6 +44,8 @@ class RKernel {
4444 console . log ( `R exited with code ${ code } ` ) ;
4545 } ) ;
4646 this . process = childProcess ;
47+
48+ return new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
4749 }
4850
4951 public stop ( ) {
@@ -60,30 +62,31 @@ class RKernel {
6062
6163 public async eval ( cell : vscode . NotebookCell ) : Promise < REvalOutput > {
6264 if ( this . process ) {
63- const client = net . createConnection ( { port : this . port } , ( ) => {
64- console . log ( 'connected to server!' ) ;
65+ const client = net . createConnection ( { host : '127.0.0.1' , port : this . port } , ( ) => {
66+ console . log ( `uri: ${ cell . uri } , connect` ) ;
6567 const request = JSON . stringify ( {
6668 time : Date . now ( ) ,
6769 expr : cell . document . getText ( ) ,
68- } ) . concat ( '\n' ) ;
69- console . log ( `Send : ${ request } ` ) ;
70+ } ) ;
71+ console . log ( `uri: ${ cell . uri } , write : ${ request } ` ) ;
7072 client . write ( request ) ;
7173 } ) ;
7274
7375 client . on ( 'end' , ( ) => {
74- console . log ( 'disconnected from server' ) ;
76+ console . log ( `uri: ${ cell . uri } , end` ) ;
7577 } ) ;
7678
7779 return new Promise ( ( resolve , reject ) => {
7880 client . on ( 'data' , ( data ) => {
7981 const response = data . toString ( ) ;
80- console . log ( response ) ;
82+ console . log ( `uri: ${ cell . uri } , data: ${ response } ` ) ;
8183 client . end ( ) ;
8284 const output : REvalOutput = JSON . parse ( response ) ;
8385 resolve ( output ) ;
8486 } ) ;
8587
8688 client . on ( 'error' , ( err ) => {
89+ console . log ( `uri: ${ cell . uri } , error: ${ err . name } , ${ err . message } ` ) ;
8790 reject ( {
8891 type : 'error' ,
8992 result : [
@@ -309,6 +312,7 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
309312 cell . metadata . runStartTime = start ;
310313 cell . metadata . executionOrder = ++ this . runIndex ;
311314 const output = await notebook . eval ( cell ) ;
315+ console . log ( `uri: ${ cell . uri } , output.type: ${ output . type } , output.result: ${ output . result } ` ) ;
312316 switch ( output . type ) {
313317 case 'text' :
314318 cell . outputs = [ {
@@ -340,7 +344,7 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
340344 }
341345 } ] ;
342346 break ;
343- case 'error' :
347+ case 'error' :
344348 throw new Error ( output . result ) ;
345349 }
346350 cell . metadata . runState = vscode . NotebookCellRunState . Success ;
0 commit comments