@@ -8,14 +8,11 @@ import type OutgoingDataStreamManager from '../../data-stream/outgoing/OutgoingD
88import type Participant from '../../participant/Participant' ;
99import {
1010 MAX_V1_PAYLOAD_BYTES ,
11- RPC_REQUEST_ID_ATTR ,
12- RPC_REQUEST_METHOD_ATTR ,
13- RPC_REQUEST_RESPONSE_TIMEOUT_MS_ATTR ,
14- RPC_REQUEST_VERSION_ATTR ,
1511 RPC_RESPONSE_DATA_STREAM_TOPIC ,
1612 RPC_VERSION_V2 ,
1713 RpcError ,
1814 type RpcInvocationData ,
15+ RpcRequestAttrs ,
1916 byteLength ,
2017} from '../utils' ;
2118import type { RpcServerManagerCallbacks } from './events' ;
@@ -105,7 +102,10 @@ export default class RpcServerManager extends (EventEmitter as new () => TypedEm
105102 `Uncaught error returned by RPC handler for ${ rpcRequest . method } . Returning APPLICATION_ERROR instead.` ,
106103 error ,
107104 ) ;
108- responseError = RpcError . builtIn ( 'APPLICATION_ERROR' ) ;
105+ responseError = RpcError . builtIn (
106+ 'APPLICATION_ERROR' ,
107+ `Uncaught error: ${ ( error as Error ) ?. message ?? error } ` ,
108+ ) ;
109109 }
110110
111111 this . publishRpcResponsePacket ( callerIdentity , rpcRequest . id , null , responseError ) ;
@@ -125,14 +125,17 @@ export default class RpcServerManager extends (EventEmitter as new () => TypedEm
125125 callerIdentity : Participant [ 'identity' ] ,
126126 dataStreamAttrs : Record < string , string > ,
127127 ) {
128- const requestId = dataStreamAttrs [ RPC_REQUEST_ID_ATTR ] ;
129- const method = dataStreamAttrs [ RPC_REQUEST_METHOD_ATTR ] ;
130- const responseTimeout = parseInt ( dataStreamAttrs [ RPC_REQUEST_RESPONSE_TIMEOUT_MS_ATTR ] , 10 ) ;
131- const version = parseInt ( dataStreamAttrs [ RPC_REQUEST_VERSION_ATTR ] , 10 ) ;
128+ const requestId = dataStreamAttrs [ RpcRequestAttrs . RPC_REQUEST_ID ] ;
129+ const method = dataStreamAttrs [ RpcRequestAttrs . RPC_REQUEST_METHOD ] ;
130+ const responseTimeout = parseInt (
131+ dataStreamAttrs [ RpcRequestAttrs . RPC_REQUEST_RESPONSE_TIMEOUT_MS ] ,
132+ 10 ,
133+ ) ;
134+ const version = parseInt ( dataStreamAttrs [ RpcRequestAttrs . RPC_REQUEST_VERSION ] , 10 ) ;
132135
133136 if ( ! requestId || ! method || Number . isNaN ( responseTimeout ) || Number . isNaN ( version ) ) {
134137 this . log . warn (
135- `RPC data stream malformed: ${ RPC_REQUEST_ID_ATTR } / ${ RPC_REQUEST_METHOD_ATTR } / ${ RPC_REQUEST_RESPONSE_TIMEOUT_MS_ATTR } / ${ RPC_REQUEST_VERSION_ATTR } not set.` ,
138+ `RPC data stream malformed: ${ RpcRequestAttrs . RPC_REQUEST_ID } / ${ RpcRequestAttrs . RPC_REQUEST_METHOD } / ${ RpcRequestAttrs . RPC_REQUEST_RESPONSE_TIMEOUT_MS } / ${ RpcRequestAttrs . RPC_REQUEST_VERSION } not set.` ,
136139 ) ;
137140 this . publishRpcResponsePacket (
138141 callerIdentity ,
@@ -262,7 +265,7 @@ export default class RpcServerManager extends (EventEmitter as new () => TypedEm
262265 const writer = await this . outgoingDataStreamManager . streamText ( {
263266 topic : RPC_RESPONSE_DATA_STREAM_TOPIC ,
264267 destinationIdentities : [ destinationIdentity ] ,
265- attributes : { [ RPC_REQUEST_ID_ATTR ] : requestId } ,
268+ attributes : { [ RpcRequestAttrs . RPC_REQUEST_ID ] : requestId } ,
266269 } ) ;
267270 await writer . write ( payload ) ;
268271 await writer . close ( ) ;
0 commit comments