File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
packages/vitest/src/runtime Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,19 @@ export async function rpcDone(): Promise<unknown[] | undefined> {
6161 return Promise . all ( awaitable )
6262}
6363
64+ let previousRpc : undefined | WorkerRPC
65+
6466export function createRuntimeRpc (
6567 options : Pick <
6668 BirpcOptions < RuntimeRPC > ,
6769 'on' | 'post' | 'serialize' | 'deserialize'
6870 > ,
6971) : { rpc : WorkerRPC ; onCancel : Promise < CancelReason > } {
72+ if ( previousRpc ) {
73+ previousRpc . $close ( )
74+ previousRpc = undefined
75+ }
76+
7077 let setCancel = ( _reason : CancelReason ) => { }
7178 const onCancel = new Promise < CancelReason > ( ( resolve ) => {
7279 setCancel = resolve
@@ -89,6 +96,8 @@ export function createRuntimeRpc(
8996 ) ,
9097 )
9198
99+ previousRpc = rpc
100+
92101 return {
93102 rpc,
94103 onCancel,
You can’t perform that action at this time.
0 commit comments