@@ -240,9 +240,21 @@ export class Context extends RpcTarget {
240240 const { accountId, instance } = instanceMetadata ;
241241
242242 try {
243+ const forceStepTimeoutKey = `force-step-timeout-${ valueKey } ` ;
244+ const forceStepTimeout =
245+ ( await this . #state. storage . get ( forceStepTimeoutKey ) ) ||
246+ ( await this . #state. storage . get (
247+ `${ forceStepTimeoutKey } -${ stepState . attemptedCount } `
248+ ) ) ;
249+
243250 const timeoutPromise = async ( ) => {
244251 const priorityQueueHash = `${ cacheKey } -${ stepState . attemptedCount } ` ;
245- const timeout = ms ( config . timeout ) ;
252+ // inserir aqui
253+ let timeout = ms ( config . timeout ) ;
254+ if ( forceStepTimeout ) {
255+ timeout = 0 ;
256+ console . log ( "[Context] I will timeout" ) ;
257+ }
246258 // @ts -expect-error priorityQueue is initiated in init
247259 await this . #engine. priorityQueue . add ( {
248260 hash : priorityQueueHash ,
@@ -304,6 +316,9 @@ export class Context extends RpcTarget {
304316 replaceResult
305317 ) ;
306318 result = replaceResult ;
319+ // if there is a timeout to be forced we dont want to race with closure
320+ } else if ( forceStepTimeout ) {
321+ result = await timeoutPromise ( ) ;
307322 } else {
308323 result = await Promise . race ( [ doWrapperClosure ( ) , timeoutPromise ( ) ] ) ;
309324 }
@@ -426,6 +441,8 @@ export class Context extends RpcTarget {
426441 // TODO (WOR-71): Think through if every Error should transition
427442 const durationMs = calcRetryDuration ( config , stepState ) ;
428443
444+ console . log ( "Vou esperar" , durationMs ) ;
445+
429446 const priorityQueueHash = `${ cacheKey } -${ stepState . attemptedCount } ` ;
430447 // @ts -expect-error priorityQueue is initiated in init
431448 await this . #engine. priorityQueue . add ( {
0 commit comments