@@ -5,13 +5,12 @@ import getPort from 'get-port';
5
5
import vscode from 'vscode' ;
6
6
import type { WebSocket } from 'ws' ;
7
7
import { WebSocketServer } from 'ws' ;
8
-
8
+ import { logger } from './logger' ;
9
9
import type {
10
10
WorkerEvent ,
11
11
WorkerEventFinish ,
12
12
WorkerRunTestData ,
13
13
} from './types' ;
14
- import { logger } from './logger' ;
15
14
16
15
export class RstestApi {
17
16
public ws : WebSocket | null = null ;
@@ -137,6 +136,10 @@ export class RstestApi {
137
136
const workerPath = path . resolve ( __dirname , 'worker.js' ) ;
138
137
const port = await getPort ( ) ;
139
138
const wsAddress = `ws://localhost:${ port } ` ;
139
+ logger . debug ( 'Spawning worker process' , {
140
+ workerPath,
141
+ wsAddress,
142
+ } ) ;
140
143
const rstestProcess = spawn ( 'node' , [ ...execArgv , workerPath ] , {
141
144
stdio : 'pipe' ,
142
145
env : {
@@ -148,19 +151,20 @@ export class RstestApi {
148
151
149
152
rstestProcess . stdout ?. on ( 'data' , ( d ) => {
150
153
const content = d . toString ( ) ;
151
- logger . debug ( '🟢 worker' , content . trimEnd ( ) ) ;
154
+ logger . debug ( 'worker stdout ' , content . trimEnd ( ) ) ;
152
155
} ) ;
153
156
154
157
rstestProcess . stderr ?. on ( 'data' , ( d ) => {
155
158
const content = d . toString ( ) ;
156
- logger . error ( '🔴 worker' , content . trimEnd ( ) ) ;
159
+ logger . error ( 'worker stderr ' , content . trimEnd ( ) ) ;
157
160
} ) ;
158
161
159
162
const server = createServer ( ) . listen ( port ) . unref ( ) ;
160
163
const wss = new WebSocketServer ( { server } ) ;
161
164
162
165
wss . once ( 'connection' , ( ws ) => {
163
166
this . ws = ws ;
167
+ logger . debug ( 'Worker connected' , { wsAddress } ) ;
164
168
const { cwd, rstestPath } = this . resolveRstestPath ( ) [ 0 ] ;
165
169
ws . send (
166
170
JSON . stringify ( {
@@ -169,11 +173,21 @@ export class RstestApi {
169
173
cwd,
170
174
} ) ,
171
175
) ;
176
+ logger . debug ( 'Sent init payload to worker' , { cwd, rstestPath } ) ;
172
177
173
178
ws . on ( 'message' , ( _data ) => {
174
179
const _message = JSON . parse ( _data . toString ( ) ) as WorkerEvent ;
175
180
if ( _message . type === 'finish' ) {
176
181
const message : WorkerEventFinish = _message ;
182
+ logger . debug ( 'Received worker completion event' , {
183
+ id : message . id ,
184
+ testResultCount : Array . isArray ( message . testResults )
185
+ ? message . testResults . length
186
+ : undefined ,
187
+ testFileResultCount : Array . isArray ( message . testFileResults )
188
+ ? message . testFileResults . length
189
+ : undefined ,
190
+ } ) ;
177
191
// Check if we have a pending promise for this test ID
178
192
const promiseObj = this . testPromises . get ( message . id ) ;
179
193
if ( promiseObj ) {
@@ -186,7 +200,9 @@ export class RstestApi {
186
200
} ) ;
187
201
} ) ;
188
202
189
- rstestProcess . on ( 'exit' , ( ) => { } ) ;
203
+ rstestProcess . on ( 'exit' , ( code , signal ) => {
204
+ logger . debug ( 'Worker process exited' , { code, signal } ) ;
205
+ } ) ;
190
206
}
191
207
192
208
public async createRstestWorker ( ) { }
0 commit comments