File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed
packages/core/src/runtime/worker Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,11 @@ const preparePool = async ({
6565
6666 const cleanupFns : ( ( ) => MaybePromise < void > ) [ ] = [ ] ;
6767
68- const { rpc } = createRuntimeRpc ( createForksRpcOptions ( ) ) ;
68+ const originalConsole = global . console ;
69+
70+ const { rpc } = createRuntimeRpc ( createForksRpcOptions ( ) , {
71+ originalConsole,
72+ } ) ;
6973 const {
7074 runtimeConfig : {
7175 globals,
Original file line number Diff line number Diff line change 11import v8 from 'node:v8' ;
22import { type BirpcOptions , type BirpcReturn , createBirpc } from 'birpc' ;
33import type { TinypoolWorkerMessage } from 'tinypool' ;
4- import type { RuntimeRPC , ServerRPC } from '../../types' ;
4+ import type { RuntimeRPC , ServerRPC , TestResult } from '../../types' ;
55
66export type WorkerRPC = BirpcReturn < RuntimeRPC , ServerRPC > ;
77
@@ -43,8 +43,37 @@ export function createRuntimeRpc(
4343 BirpcOptions < void > ,
4444 'on' | 'post' | 'serialize' | 'deserialize'
4545 > ,
46+ {
47+ originalConsole,
48+ } : {
49+ originalConsole : Console ;
50+ } ,
4651) : { rpc : WorkerRPC } {
47- const rpc = createBirpc < RuntimeRPC , ServerRPC > ( { } , options ) ;
52+ const rpc = createBirpc < RuntimeRPC , ServerRPC > (
53+ { } ,
54+ {
55+ ...options ,
56+ onTimeoutError : ( functionName , error ) => {
57+ switch ( functionName ) {
58+ case 'onTestCaseResult' : {
59+ const caseResult = error [ 0 ] as unknown as TestResult ;
60+ console . error (
61+ `[Rstest] timeout on calling "onTestCaseResult" rpc method (Case: "${ caseResult . name } ", Result: "${ caseResult . status } ")` ,
62+ ) ;
63+ return true ;
64+ }
65+ case 'onConsoleLog' : {
66+ originalConsole . error (
67+ `[Rstest] timeout on calling "onConsoleLog" rpc method (Original log: ${ error [ 0 ] . content } )` ,
68+ ) ;
69+ return true ;
70+ }
71+ default :
72+ return false ;
73+ }
74+ } ,
75+ } ,
76+ ) ;
4877
4978 return {
5079 rpc,
You can’t perform that action at this time.
0 commit comments