@@ -13,6 +13,7 @@ import {
1313import { recordSpanException , TracingSDK } from "../otel/index.js" ;
1414import { runTimelineMetrics } from "../run-timeline-metrics-api.js" ;
1515import {
16+ RetryOptions ,
1617 ServerBackgroundWorker ,
1718 TaskRunContext ,
1819 TaskRunErrorCodes ,
@@ -39,15 +40,23 @@ export type TaskExecutorOptions = {
3940 tracingSDK : TracingSDK ;
4041 tracer : TriggerTracer ;
4142 consoleInterceptor : ConsoleInterceptor ;
42- config : TriggerConfig | undefined ;
43+ retries ?: {
44+ enabledInDev ?: boolean ;
45+ default ?: RetryOptions ;
46+ } ;
4347 handleErrorFn : HandleErrorFunction | undefined ;
4448} ;
4549
4650export class TaskExecutor {
4751 private _tracingSDK : TracingSDK ;
4852 private _tracer : TriggerTracer ;
4953 private _consoleInterceptor : ConsoleInterceptor ;
50- private _importedConfig : TriggerConfig | undefined ;
54+ private _retries :
55+ | {
56+ enabledInDev ?: boolean ;
57+ default ?: RetryOptions ;
58+ }
59+ | undefined ;
5160 private _handleErrorFn : HandleErrorFunction | undefined ;
5261
5362 constructor (
@@ -57,15 +66,14 @@ export class TaskExecutor {
5766 this . _tracingSDK = options . tracingSDK ;
5867 this . _tracer = options . tracer ;
5968 this . _consoleInterceptor = options . consoleInterceptor ;
60- this . _importedConfig = options . config ;
69+ this . _retries = options . retries ;
6170 this . _handleErrorFn = options . handleErrorFn ;
6271 }
6372
6473 async execute (
6574 execution : TaskRunExecution ,
6675 worker : ServerBackgroundWorker ,
6776 traceContext : Record < string , unknown > ,
68- usage : UsageMeasurement ,
6977 signal ?: AbortSignal
7078 ) : Promise < { result : TaskRunExecutionResult } > {
7179 const ctx = TaskRunContext . parse ( execution ) ;
@@ -665,7 +673,7 @@ export class TaskExecutor {
665673 | { status : "skipped" ; error ?: unknown } // skipped is different than noop, it means that the task was skipped from retrying, instead of just not retrying
666674 | { status : "noop" ; error ?: unknown }
667675 > {
668- const retriesConfig = this . _importedConfig ?. retries ;
676+ const retriesConfig = this . _retries ;
669677
670678 const retry = this . task . retry ?? retriesConfig ?. default ;
671679
@@ -721,8 +729,8 @@ export class TaskExecutor {
721729 retryAt : delay ? new Date ( Date . now ( ) + delay ) : undefined ,
722730 signal,
723731 } )
724- : this . _importedConfig
725- ? await this . _handleErrorFn ?. ( payload , error , {
732+ : this . _handleErrorFn
733+ ? await this . _handleErrorFn ( payload , error , {
726734 ctx,
727735 init,
728736 retry,
0 commit comments