File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
packages/vite/src/node/server Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ export interface NormalizedHotChannel<Api = any> {
157157 off ( event : string , listener : Function ) : void
158158 /** @internal */
159159 setInvokeHandler ( invokeHandlers : InvokeMethods | undefined ) : void
160- handleInvoke ( payload : HotPayload ) : Promise < { r : any } | { e : any } >
160+ handleInvoke ( payload : HotPayload ) : Promise < { result : any } | { error : any } >
161161 /**
162162 * Start listening for messages
163163 */
@@ -301,7 +301,13 @@ export const normalizeHotChannel = (
301301 }
302302 channel . on ?.( 'vite:invoke' , listenerForInvokeHandler )
303303 } ,
304- handleInvoke,
304+ handleInvoke : async ( payload ) => {
305+ const data = await handleInvoke ( payload )
306+ if ( data . e ) {
307+ return { error : data . e }
308+ }
309+ return { result : data . r }
310+ } ,
305311 send : ( ...args : any [ ] ) => {
306312 let payload : HotPayload
307313 if ( typeof args [ 0 ] === 'string' ) {
@@ -1161,7 +1167,7 @@ export function createDeprecatedHotBroadcaster(
11611167 send : ws . send ,
11621168 setInvokeHandler : ws . setInvokeHandler ,
11631169 handleInvoke : async ( ) => ( {
1164- e : {
1170+ error : {
11651171 name : 'TransportError' ,
11661172 message : 'handleInvoke not implemented' ,
11671173 stack : new Error ( ) . stack ,
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ export function createWebSocketServer(
105105 off : noop as any as WebSocketServer [ 'off' ] ,
106106 setInvokeHandler : noop ,
107107 handleInvoke : async ( ) => ( {
108- e : {
108+ error : {
109109 name : 'TransportError' ,
110110 message : 'handleInvoke not implemented' ,
111111 stack : new Error ( ) . stack ,
You can’t perform that action at this time.
0 commit comments