@@ -2,6 +2,7 @@ import { randomString } from "functools-kit";
22import swarm , { ExecutionContextService } from "../../lib" ;
33import { GLOBAL_CONFIG } from "../../config/params" ;
44import beginContext from "../../utils/beginContext" ;
5+ import { errorSubject } from "../../config/emitters" ;
56
67const METHOD_NAME = "function.target.runStatelessForce" ;
78
@@ -32,23 +33,40 @@ const runStatelessForceInternal = beginContext(
3233 swarm . perfService . startExecution ( executionId , clientId , content . length ) ;
3334 try {
3435 swarm . busService . commitExecutionBegin ( clientId , { swarmName } ) ;
35- const result = await swarm . sessionPublicService . run (
36+
37+ let result = "" ;
38+ let errorValue = null ;
39+
40+ const unError = errorSubject . once ( ( [ errorClientId , error ] ) => {
41+ if ( clientId === errorClientId ) {
42+ errorValue = error ;
43+ }
44+ } ) ;
45+
46+ result = await swarm . sessionPublicService . run (
3647 content ,
3748 METHOD_NAME ,
3849 clientId ,
3950 swarmName
4051 ) ;
52+
53+ unError ( ) ;
54+
55+ if ( errorValue ) {
56+ throw errorValue ;
57+ }
58+
4159 isFinished = swarm . perfService . endExecution (
4260 executionId ,
4361 clientId ,
4462 result . length
4563 ) ;
46- swarm . busService . commitExecutionEnd ( clientId , { swarmName } ) ;
4764 return result ;
4865 } finally {
4966 if ( ! isFinished ) {
5067 swarm . perfService . endExecution ( executionId , clientId , 0 ) ;
5168 }
69+ swarm . busService . commitExecutionEnd ( clientId , { swarmName } ) ;
5270 swarm . executionValidationService . decrementCount ( executionId , clientId , swarmName ) ;
5371 }
5472 } ,
0 commit comments