Skip to content

Commit ba520fc

Browse files
committed
Make sure and register all the config hooks
1 parent 23ae77a commit ba520fc

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

packages/cli-v3/src/entryPoints/dev-run-worker.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,44 @@ async function bootstrap() {
183183

184184
if (config.init) {
185185
lifecycleHooks.registerGlobalInitHook({
186-
id: "trigger-dev-worker",
186+
id: "config",
187187
fn: lifecycleHooksAdapters.createInitHookAdapter(config.init),
188188
});
189189
}
190190

191191
if (config.onStart) {
192192
lifecycleHooks.registerGlobalStartHook({
193-
id: "trigger-dev-worker",
193+
id: "config",
194194
fn: lifecycleHooksAdapters.createStartHookAdapter(config.onStart),
195195
});
196196
}
197197

198+
if (config.onSuccess) {
199+
lifecycleHooks.registerGlobalSuccessHook({
200+
id: "config",
201+
fn: lifecycleHooksAdapters.createSuccessHookAdapter(config.onSuccess),
202+
});
203+
}
204+
205+
if (config.onFailure) {
206+
lifecycleHooks.registerGlobalFailureHook({
207+
id: "config",
208+
fn: lifecycleHooksAdapters.createFailureHookAdapter(config.onFailure),
209+
});
210+
}
211+
212+
if (handleError) {
213+
lifecycleHooks.registerGlobalCatchErrorHook({
214+
id: "config",
215+
fn: lifecycleHooksAdapters.createHandleErrorHookAdapter(handleError),
216+
});
217+
}
218+
198219
return {
199220
tracer,
200221
tracingSDK,
201222
consoleInterceptor,
202223
config,
203-
handleErrorFn: handleError,
204224
workerManifest,
205225
};
206226
}
@@ -242,7 +262,7 @@ const zodIpc = new ZodIpcConnection({
242262
}
243263

244264
try {
245-
const { tracer, tracingSDK, consoleInterceptor, config, handleErrorFn, workerManifest } =
265+
const { tracer, tracingSDK, consoleInterceptor, config, workerManifest } =
246266
await bootstrap();
247267

248268
_tracingSDK = tracingSDK;
@@ -359,7 +379,6 @@ const zodIpc = new ZodIpcConnection({
359379
tracingSDK,
360380
consoleInterceptor,
361381
retries: config.retries,
362-
handleErrorFn,
363382
});
364383

365384
try {

packages/core/src/v3/types/tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export type HandleErrorResult =
133133

134134
export type HandleErrorArgs = {
135135
ctx: Context;
136-
init: unknown;
136+
init?: Record<string, unknown>;
137137
retry?: RetryOptions;
138138
retryAt?: Date;
139139
retryDelayInMs?: number;

packages/core/src/v3/workers/taskExecutor.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export type TaskExecutorOptions = {
5353
enabledInDev?: boolean;
5454
default?: RetryOptions;
5555
};
56-
handleErrorFn: HandleErrorFunction | undefined;
5756
};
5857

5958
export class TaskExecutor {
@@ -66,7 +65,6 @@ export class TaskExecutor {
6665
default?: RetryOptions;
6766
}
6867
| undefined;
69-
private _handleErrorFn: HandleErrorFunction | undefined;
7068

7169
constructor(
7270
public task: TaskMetadataWithFunctions,
@@ -76,7 +74,6 @@ export class TaskExecutor {
7674
this._tracer = options.tracer;
7775
this._consoleInterceptor = options.consoleInterceptor;
7876
this._retries = options.retries;
79-
this._handleErrorFn = options.handleErrorFn;
8077
}
8178

8279
async execute(

packages/core/test/taskExecutor.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,6 @@ function executeTask(task: TaskMetadataWithFunctions, payload: any, signal?: Abo
15311531
maxAttempts: 1,
15321532
},
15331533
},
1534-
handleErrorFn: undefined,
15351534
});
15361535

15371536
const execution: TaskRunExecution = {

0 commit comments

Comments
 (0)