@@ -44,6 +44,8 @@ class RKernel {
44
44
console . log ( `R exited with code ${ code } ` ) ;
45
45
} ) ;
46
46
this . process = childProcess ;
47
+
48
+ return new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
47
49
}
48
50
49
51
public stop ( ) {
@@ -60,30 +62,31 @@ class RKernel {
60
62
61
63
public async eval ( cell : vscode . NotebookCell ) : Promise < REvalOutput > {
62
64
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` ) ;
65
67
const request = JSON . stringify ( {
66
68
time : Date . now ( ) ,
67
69
expr : cell . document . getText ( ) ,
68
- } ) . concat ( '\n' ) ;
69
- console . log ( `Send : ${ request } ` ) ;
70
+ } ) ;
71
+ console . log ( `uri: ${ cell . uri } , write : ${ request } ` ) ;
70
72
client . write ( request ) ;
71
73
} ) ;
72
74
73
75
client . on ( 'end' , ( ) => {
74
- console . log ( 'disconnected from server' ) ;
76
+ console . log ( `uri: ${ cell . uri } , end` ) ;
75
77
} ) ;
76
78
77
79
return new Promise ( ( resolve , reject ) => {
78
80
client . on ( 'data' , ( data ) => {
79
81
const response = data . toString ( ) ;
80
- console . log ( response ) ;
82
+ console . log ( `uri: ${ cell . uri } , data: ${ response } ` ) ;
81
83
client . end ( ) ;
82
84
const output : REvalOutput = JSON . parse ( response ) ;
83
85
resolve ( output ) ;
84
86
} ) ;
85
87
86
88
client . on ( 'error' , ( err ) => {
89
+ console . log ( `uri: ${ cell . uri } , error: ${ err . name } , ${ err . message } ` ) ;
87
90
reject ( {
88
91
type : 'error' ,
89
92
result : [
@@ -309,6 +312,7 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
309
312
cell . metadata . runStartTime = start ;
310
313
cell . metadata . executionOrder = ++ this . runIndex ;
311
314
const output = await notebook . eval ( cell ) ;
315
+ console . log ( `uri: ${ cell . uri } , output.type: ${ output . type } , output.result: ${ output . result } ` ) ;
312
316
switch ( output . type ) {
313
317
case 'text' :
314
318
cell . outputs = [ {
@@ -340,7 +344,7 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
340
344
}
341
345
} ] ;
342
346
break ;
343
- case 'error' :
347
+ case 'error' :
344
348
throw new Error ( output . result ) ;
345
349
}
346
350
cell . metadata . runState = vscode . NotebookCellRunState . Success ;
0 commit comments