File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change 3
3
CancelledNotificationSchema ,
4
4
ClientCapabilities ,
5
5
ErrorCode ,
6
+ isJSONRPCError ,
6
7
isJSONRPCRequest ,
7
8
isJSONRPCResponse ,
8
9
isJSONRPCNotification ,
@@ -274,7 +275,7 @@ export abstract class Protocol<
274
275
} ;
275
276
276
277
this . _transport . onmessage = ( message ) => {
277
- if ( isJSONRPCResponse ( message ) ) {
278
+ if ( isJSONRPCResponse ( message ) || isJSONRPCError ( message ) ) {
278
279
this . _onresponse ( message ) ;
279
280
} else if ( isJSONRPCRequest ( message ) ) {
280
281
this . _onrequest ( message ) ;
Original file line number Diff line number Diff line change @@ -150,6 +150,9 @@ export const JSONRPCErrorSchema = z
150
150
} )
151
151
. strict ( ) ;
152
152
153
+ export const isJSONRPCError = ( value : unknown ) : value is JSONRPCError =>
154
+ JSONRPCErrorSchema . safeParse ( value ) . success ;
155
+
153
156
export const JSONRPCMessageSchema = z . union ( [
154
157
JSONRPCRequestSchema ,
155
158
JSONRPCNotificationSchema ,
You can’t perform that action at this time.
0 commit comments