@@ -458,7 +458,7 @@ export class ActorInstance<S, CP, CS, V> {
458458 }
459459 }
460460
461- // State will be flushed at the end of the RPC
461+ // State will be flushed at the end of the action
462462 } ,
463463 { ignoreDetached : true } ,
464464 ) ;
@@ -734,8 +734,8 @@ export class ActorInstance<S, CP, CS, V> {
734734 // MARK: Messages
735735 async processMessage ( message : wsToServer . ToServer , conn : Conn < S , CP , CS , V > ) {
736736 await processMessage ( message , this , conn , {
737- onExecuteRpc : async ( ctx , name , args ) => {
738- return await this . executeRpc ( ctx , name , args ) ;
737+ onExecuteAction : async ( ctx , name , args ) => {
738+ return await this . executeAction ( ctx , name , args ) ;
739739 } ,
740740 onSubscribe : async ( eventName , conn ) => {
741741 this . #addSubscription( eventName , conn , false ) ;
@@ -820,98 +820,98 @@ export class ActorInstance<S, CP, CS, V> {
820820 }
821821
822822 /**
823- * Execute an RPC call from a client.
823+ * Execute an action call from a client.
824824 *
825825 * This method handles:
826- * 1. Validating the RPC name
827- * 2. Executing the RPC function
828- * 3. Processing the result through onBeforeRpcResponse (if configured)
826+ * 1. Validating the action name
827+ * 2. Executing the action function
828+ * 3. Processing the result through onBeforeActionResponse (if configured)
829829 * 4. Handling timeouts and errors
830830 * 5. Saving state changes
831831 *
832- * @param ctx The RPC context
833- * @param rpcName The name of the RPC being called
834- * @param args The arguments passed to the RPC
835- * @returns The result of the RPC call
836- * @throws {RpcNotFound } If the RPC doesn't exist
837- * @throws {RpcTimedOut } If the RPC times out
832+ * @param ctx The action context
833+ * @param actionName The name of the action being called
834+ * @param args The arguments passed to the action
835+ * @returns The result of the action call
836+ * @throws {ActionNotFound } If the action doesn't exist
837+ * @throws {ActionTimedOut } If the action times out
838838 * @internal
839839 */
840- async executeRpc (
840+ async executeAction (
841841 ctx : ActionContext < S , CP , CS , V > ,
842- rpcName : string ,
842+ actionName : string ,
843843 args : unknown [ ] ,
844844 ) : Promise < unknown > {
845- invariant ( this . #ready, "exucuting rpc before ready" ) ;
845+ invariant ( this . #ready, "exucuting action before ready" ) ;
846846
847847 // Prevent calling private or reserved methods
848- if ( ! ( rpcName in this . #config. actions ) ) {
849- logger ( ) . warn ( "rpc does not exist" , { rpcName } ) ;
848+ if ( ! ( actionName in this . #config. actions ) ) {
849+ logger ( ) . warn ( "action does not exist" , { actionName } ) ;
850850 throw new errors . ActionNotFound ( ) ;
851851 }
852852
853853 // Check if the method exists on this object
854- // biome-ignore lint/suspicious/noExplicitAny: RPC name is dynamic from client
855- const rpcFunction = this . #config. actions [ rpcName ] ;
856- if ( typeof rpcFunction !== "function" ) {
857- logger ( ) . warn ( "action not found" , { actionName : rpcName } ) ;
854+ // biome-ignore lint/suspicious/noExplicitAny: action name is dynamic from client
855+ const actionFunction = this . #config. actions [ actionName ] ;
856+ if ( typeof actionFunction !== "function" ) {
857+ logger ( ) . warn ( "action not found" , { actionName : actionName } ) ;
858858 throw new errors . ActionNotFound ( ) ;
859859 }
860860
861- // TODO: pass abortable to the rpc to decide when to abort
861+ // TODO: pass abortable to the action to decide when to abort
862862 // TODO: Manually call abortable for better error handling
863863 // Call the function on this object with those arguments
864864 try {
865865 // Log when we start executing the action
866- logger ( ) . debug ( "executing action" , { actionName : rpcName , args } ) ;
866+ logger ( ) . debug ( "executing action" , { actionName : actionName , args } ) ;
867867
868- const outputOrPromise = rpcFunction . call ( undefined , ctx , ...args ) ;
868+ const outputOrPromise = actionFunction . call ( undefined , ctx , ...args ) ;
869869 let output : unknown ;
870870 if ( outputOrPromise instanceof Promise ) {
871871 // Log that we're waiting for an async action
872- logger ( ) . debug ( "awaiting async action" , { actionName : rpcName } ) ;
872+ logger ( ) . debug ( "awaiting async action" , { actionName : actionName } ) ;
873873
874874 output = await deadline (
875875 outputOrPromise ,
876876 this . #config. options . action . timeout ,
877877 ) ;
878878
879879 // Log that async action completed
880- logger ( ) . debug ( "async action completed" , { actionName : rpcName } ) ;
880+ logger ( ) . debug ( "async action completed" , { actionName : actionName } ) ;
881881 } else {
882882 output = outputOrPromise ;
883883 }
884884
885- // Process the output through onBeforeRpcResponse if configured
885+ // Process the output through onBeforeActionResponse if configured
886886 if ( this . #config. onBeforeActionResponse ) {
887887 try {
888888 const processedOutput = this . #config. onBeforeActionResponse (
889889 this . actorContext ,
890- rpcName ,
890+ actionName ,
891891 args ,
892892 output ,
893893 ) ;
894894 if ( processedOutput instanceof Promise ) {
895895 logger ( ) . debug ( "awaiting onBeforeActionResponse" , {
896- actionName : rpcName ,
896+ actionName : actionName ,
897897 } ) ;
898898 output = await processedOutput ;
899899 logger ( ) . debug ( "onBeforeActionResponse completed" , {
900- actionName : rpcName ,
900+ actionName : actionName ,
901901 } ) ;
902902 } else {
903903 output = processedOutput ;
904904 }
905905 } catch ( error ) {
906- logger ( ) . error ( "error in `onBeforeRpcResponse `" , {
906+ logger ( ) . error ( "error in `onBeforeActionResponse `" , {
907907 error : stringifyError ( error ) ,
908908 } ) ;
909909 }
910910 }
911911
912912 // Log the output before returning
913913 logger ( ) . debug ( "action completed" , {
914- actionName : rpcName ,
914+ actionName : actionName ,
915915 outputType : typeof output ,
916916 isPromise : output instanceof Promise ,
917917 } ) ;
@@ -922,7 +922,7 @@ export class ActorInstance<S, CP, CS, V> {
922922 throw new errors . ActionTimedOut ( ) ;
923923 }
924924 logger ( ) . error ( "action error" , {
925- actionName : rpcName ,
925+ actionName : actionName ,
926926 error : stringifyError ( error ) ,
927927 } ) ;
928928 throw error ;
@@ -932,9 +932,9 @@ export class ActorInstance<S, CP, CS, V> {
932932 }
933933
934934 /**
935- * Returns a list of RPC methods available on this actor.
935+ * Returns a list of action methods available on this actor.
936936 */
937- get rpcs ( ) : string [ ] {
937+ get actions ( ) : string [ ] {
938938 return Object . keys ( this . #config. actions ) ;
939939 }
940940
@@ -1040,7 +1040,7 @@ export class ActorInstance<S, CP, CS, V> {
10401040 * Runs a promise in the background.
10411041 *
10421042 * This allows the actor runtime to ensure that a promise completes while
1043- * returning from an RPC request early.
1043+ * returning from an action request early.
10441044 *
10451045 * @param promise - The promise to run in the background.
10461046 */
0 commit comments