File tree 3 files changed +5
-7
lines changed
3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,8 @@ function createChannel(ctx: Vitest) {
140
140
141
141
createBirpc < { } , WorkerRPC > (
142
142
{
143
- onWorkerExit ( code ) {
143
+ async onWorkerExit ( error , code ) {
144
+ await ctx . logger . printError ( error , false , 'Unexpected Exit' )
144
145
process . exit ( code || 1 )
145
146
} ,
146
147
snapshotSaved ( snapshot ) {
Original file line number Diff line number Diff line change @@ -23,12 +23,9 @@ async function startViteNode(ctx: WorkerContext) {
23
23
24
24
const processExit = process . exit
25
25
26
- process . on ( 'beforeExit' , ( code ) => {
27
- rpc ( ) . onWorkerExit ( code )
28
- } )
29
-
30
26
process . exit = ( code = process . exitCode || 0 ) : never => {
31
- rpc ( ) . onWorkerExit ( code )
27
+ const error = new Error ( `process.exit called with "${ code } "` )
28
+ rpc ( ) . onWorkerExit ( error , code )
32
29
return processExit ( code )
33
30
}
34
31
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export interface WorkerRPC {
27
27
getSourceMap : ( id : string , force ?: boolean ) => Promise < RawSourceMap | undefined >
28
28
29
29
onFinished : ( files : File [ ] , errors ?: unknown [ ] ) => void
30
- onWorkerExit : ( code ?: number ) => void
30
+ onWorkerExit : ( error : unknown , code ?: number ) => void
31
31
onPathsCollected : ( paths : string [ ] ) => void
32
32
onUserConsoleLog : ( log : UserConsoleLog ) => void
33
33
onUnhandledRejection : ( err : unknown ) => void
You can’t perform that action at this time.
0 commit comments