File tree Expand file tree Collapse file tree 4 files changed +17
-29
lines changed
rivetkit-typescript/packages/rivetkit/src
schemas/client-protocol-zod Expand file tree Collapse file tree 4 files changed +17
-29
lines changed Original file line number Diff line number Diff line change @@ -299,29 +299,20 @@ export async function processMessage<
299299 errorData ,
300300 TO_CLIENT_VERSIONED ,
301301 ToClientSchema ,
302- // JSON: metadata is the raw value (keep as undefined if not present)
303- ( value ) : ToClientJson => {
304- const val : any = {
305- group : value . group ,
306- code : value . code ,
307- message : value . message ,
308- actionId :
309- value . actionId !== undefined
310- ? value . actionId
311- : null ,
312- } ;
313- if ( value . metadata !== undefined ) {
314- val . metadata = value . metadata ;
315- }
316- return {
317- body : {
318- tag : "Error" as const ,
319- val,
302+ // JSON: metadata is the raw value
303+ ( value ) : ToClientJson => ( {
304+ body : {
305+ tag : "Error" as const ,
306+ val : {
307+ group : value . group ,
308+ code : value . code ,
309+ message : value . message ,
310+ metadata : value . metadata ?? null ,
311+ actionId : value . actionId ?? null ,
320312 } ,
321- } ;
322- } ,
313+ } ,
314+ } ) ,
323315 // BARE/CBOR: metadata needs to be CBOR-encoded to ArrayBuffer
324- // Note: protocol.Error expects `| null` for optional fields (BARE protocol)
325316 ( value ) : protocol . ToClient => ( {
326317 body : {
327318 tag : "Error" as const ,
@@ -334,10 +325,7 @@ export async function processMessage<
334325 cbor . encode ( value . metadata ) ,
335326 )
336327 : null ,
337- actionId :
338- value . actionId !== undefined
339- ? value . actionId
340- : null ,
328+ actionId : value . actionId ?? null ,
341329 } ,
342330 } ,
343331 } ) ,
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ export async function sendHttpRequest<
157157 message : bare . message ,
158158 metadata : bare . metadata
159159 ? cbor . decode ( new Uint8Array ( bare . metadata ) )
160- : undefined ,
160+ : null ,
161161 } ) ,
162162 ) ;
163163 } catch ( error ) {
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ export function handleRouteError(error: unknown, c: HonoContext) {
8282 group : value . group ,
8383 code : value . code ,
8484 message : value . message ,
85- metadata : value . metadata ,
85+ metadata : value . metadata ?? null ,
8686 } ) ,
8787 // BARE/CBOR: metadata needs to be CBOR-encoded to ArrayBuffer
8888 ( value ) : protocol . HttpResponseError => ( {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export const ErrorSchema = z.object({
1515 group : z . string ( ) ,
1616 code : z . string ( ) ,
1717 message : z . string ( ) ,
18- metadata : z . unknown ( ) . optional ( ) ,
18+ metadata : z . unknown ( ) . nullable ( ) ,
1919 actionId : OptionalUintSchema ,
2020} ) ;
2121export type Error = z . infer < typeof ErrorSchema > ;
@@ -89,7 +89,7 @@ export const HttpResponseErrorSchema = z.object({
8989 group : z . string ( ) ,
9090 code : z . string ( ) ,
9191 message : z . string ( ) ,
92- metadata : z . unknown ( ) . optional ( ) ,
92+ metadata : z . unknown ( ) . nullable ( ) ,
9393} ) ;
9494export type HttpResponseError = z . infer < typeof HttpResponseErrorSchema > ;
9595
You can’t perform that action at this time.
0 commit comments