Make sure and register all the config hooks

This commit is contained in:
Eric Allam
2025-03-25 11:55:54 +00:00
parent 23ae77afff
commit ba520fcdd8
4 changed files with 25 additions and 10 deletions
@@ -183,24 +183,44 @@ async function bootstrap() {
if (config.init) {
lifecycleHooks.registerGlobalInitHook({
id: "trigger-dev-worker",
id: "config",
fn: lifecycleHooksAdapters.createInitHookAdapter(config.init),
});
}
if (config.onStart) {
lifecycleHooks.registerGlobalStartHook({
id: "trigger-dev-worker",
id: "config",
fn: lifecycleHooksAdapters.createStartHookAdapter(config.onStart),
});
}
if (config.onSuccess) {
lifecycleHooks.registerGlobalSuccessHook({
id: "config",
fn: lifecycleHooksAdapters.createSuccessHookAdapter(config.onSuccess),
});
}
if (config.onFailure) {
lifecycleHooks.registerGlobalFailureHook({
id: "config",
fn: lifecycleHooksAdapters.createFailureHookAdapter(config.onFailure),
});
}
if (handleError) {
lifecycleHooks.registerGlobalCatchErrorHook({
id: "config",
fn: lifecycleHooksAdapters.createHandleErrorHookAdapter(handleError),
});
}
return {
tracer,
tracingSDK,
consoleInterceptor,
config,
handleErrorFn: handleError,
workerManifest,
};
}
@@ -242,7 +262,7 @@ const zodIpc = new ZodIpcConnection({
}
try {
const { tracer, tracingSDK, consoleInterceptor, config, handleErrorFn, workerManifest } =
const { tracer, tracingSDK, consoleInterceptor, config, workerManifest } =
await bootstrap();
_tracingSDK = tracingSDK;
@@ -359,7 +379,6 @@ const zodIpc = new ZodIpcConnection({
tracingSDK,
consoleInterceptor,
retries: config.retries,
handleErrorFn,
});
try {
+1 -1
View File
@@ -133,7 +133,7 @@ export type HandleErrorResult =
export type HandleErrorArgs = {
ctx: Context;
init: unknown;
init?: Record<string, unknown>;
retry?: RetryOptions;
retryAt?: Date;
retryDelayInMs?: number;
@@ -53,7 +53,6 @@ export type TaskExecutorOptions = {
enabledInDev?: boolean;
default?: RetryOptions;
};
handleErrorFn: HandleErrorFunction | undefined;
};
export class TaskExecutor {
@@ -66,7 +65,6 @@ export class TaskExecutor {
default?: RetryOptions;
}
| undefined;
private _handleErrorFn: HandleErrorFunction | undefined;
constructor(
public task: TaskMetadataWithFunctions,
@@ -76,7 +74,6 @@ export class TaskExecutor {
this._tracer = options.tracer;
this._consoleInterceptor = options.consoleInterceptor;
this._retries = options.retries;
this._handleErrorFn = options.handleErrorFn;
}
async execute(
-1
View File
@@ -1531,7 +1531,6 @@ function executeTask(task: TaskMetadataWithFunctions, payload: any, signal?: Abo
maxAttempts: 1,
},
},
handleErrorFn: undefined,
});
const execution: TaskRunExecution = {