Skip to content

Commit a75fc31

Browse files
fix: make result interfaces for ModuleRunnerTransport#invoke more explicit (#18851)
1 parent 44a0f40 commit a75fc31

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

docs/guide/api-environment-runtimes.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,7 @@ interface ModuleRunnerTransport {
265265
connect?(handlers: ModuleRunnerTransportHandlers): Promise<void> | void
266266
disconnect?(): Promise<void> | void
267267
send?(data: HotPayload): Promise<void> | void
268-
invoke?(
269-
data: HotPayload,
270-
): Promise<{ /** result */ r: any } | { /** error */ e: any }>
268+
invoke?(data: HotPayload): Promise<{ result: any } | { error: any }>
271269
timeout?: number
272270
}
273271
```

packages/vite/src/shared/moduleRunnerTransport.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export interface ModuleRunnerTransport {
1919
connect?(handlers: ModuleRunnerTransportHandlers): Promise<void> | void
2020
disconnect?(): Promise<void> | void
2121
send?(data: HotPayload): Promise<void> | void
22-
invoke?(
23-
data: HotPayload,
24-
): Promise<{ /** result */ r: any } | { /** error */ e: any }>
22+
invoke?(data: HotPayload): Promise<{ result: any } | { error: any }>
2523
timeout?: number
2624
}
2725

@@ -58,10 +56,10 @@ const createInvokeableTransport = (
5856
data,
5957
} satisfies InvokeSendData,
6058
} satisfies CustomPayload)
61-
if ('e' in result) {
62-
throw reviveInvokeError(result.e)
59+
if ('error' in result) {
60+
throw reviveInvokeError(result.error)
6361
}
64-
return result.r
62+
return result.result
6563
},
6664
}
6765
}

0 commit comments

Comments
 (0)