Skip to content

Commit a6e04bd

Browse files
authoredFeb 5, 2024
fix: rpc timeout error messages to include caller (#5103)
1 parent 2494fbf commit a6e04bd

File tree

11 files changed

+37
-11
lines changed

11 files changed

+37
-11
lines changed
 

‎packages/ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"@vitest/ws-client": "workspace:*",
7373
"@vueuse/core": "^10.6.1",
7474
"ansi-to-html": "^0.7.2",
75-
"birpc": "0.2.14",
75+
"birpc": "0.2.15",
7676
"codemirror": "^5.65.16",
7777
"codemirror-theme-vars": "^0.1.2",
7878
"cypress": "^13.6.2",

‎packages/vitest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"@types/node": "^20.11.5",
177177
"@types/prompts": "^2.4.9",
178178
"@types/sinonjs__fake-timers": "^8.1.5",
179-
"birpc": "0.2.14",
179+
"birpc": "0.2.15",
180180
"chai-subset": "^1.6.0",
181181
"cli-truncate": "^4.0.0",
182182
"expect-type": "^0.17.3",

‎packages/vitest/src/api/setup.ts

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ export function setup(vitestOrWorkspace: Vitest | WorkspaceProject, _server?: Vi
157157
eventNames: ['onUserConsoleLog', 'onFinished', 'onCollected', 'onCancel'],
158158
serialize: (data: any) => stringify(data, stringifyReplace),
159159
deserialize: parse,
160+
onTimeoutError(functionName) {
161+
throw new Error(`[vitest-api]: Timeout calling "${functionName}"`)
162+
},
160163
},
161164
)
162165

‎packages/vitest/src/node/pools/forks.ts

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ function createChildProcessChannel(project: WorkspaceProject) {
3333
on(fn) {
3434
emitter.on(events.response, fn)
3535
},
36+
onTimeoutError(functionName) {
37+
throw new Error(`[vitest-pool]: Timeout calling "${functionName}"`)
38+
},
3639
},
3740
)
3841

‎packages/vitest/src/node/pools/threads.ts

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ function createWorkerChannel(project: WorkspaceProject) {
2626
on(fn) {
2727
port.on('message', fn)
2828
},
29+
onTimeoutError(functionName) {
30+
throw new Error(`[vitest-pool]: Timeout calling "${functionName}"`)
31+
},
2932
},
3033
)
3134

‎packages/vitest/src/node/pools/vmForks.ts

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ function createChildProcessChannel(project: WorkspaceProject) {
3838
on(fn) {
3939
emitter.on(events.response, fn)
4040
},
41+
onTimeoutError(functionName) {
42+
throw new Error(`[vitest-pool]: Timeout calling "${functionName}"`)
43+
},
4144
},
4245
)
4346

‎packages/vitest/src/node/pools/vmThreads.ts

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ function createWorkerChannel(project: WorkspaceProject) {
3030
on(fn) {
3131
port.on('message', fn)
3232
},
33+
onTimeoutError(functionName) {
34+
throw new Error(`[vitest-pool]: Timeout calling "${functionName}"`)
35+
},
3336
},
3437
)
3538

‎packages/vitest/src/runtime/rpc.ts

+8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ export function createRuntimeRpc(options: Pick<BirpcOptions<RuntimeRPC>, 'on' |
6767
},
6868
{
6969
eventNames: ['onUserConsoleLog', 'onFinished', 'onCollected', 'onCancel'],
70+
onTimeoutError(functionName, args) {
71+
let message = `[vitest-worker]: Timeout calling "${functionName}"`
72+
73+
if (functionName === 'fetch' || functionName === 'transform' || functionName === 'resolveId')
74+
message += ` with "${JSON.stringify(args)}"`
75+
76+
throw new Error(message)
77+
},
7078
...options,
7179
},
7280
))

‎packages/ws-client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"typecheck": "tsc --noEmit"
4040
},
4141
"dependencies": {
42-
"birpc": "0.2.14",
42+
"birpc": "0.2.15",
4343
"flatted": "^3.2.9",
4444
"ws": "^8.14.2"
4545
},

‎packages/ws-client/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ export function createClient(url: string, options: VitestClientOptions = {}) {
7878
on: fn => (onMessage = fn),
7979
serialize: stringify,
8080
deserialize: parse,
81+
onTimeoutError(functionName) {
82+
throw new Error(`[vitest-ws-client]: Timeout calling "${functionName}"`)
83+
},
8184
}
8285

8386
ctx.rpc = createBirpc<WebSocketHandlers, WebSocketEvents>(

‎pnpm-lock.yaml

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.